Created
November 9, 2022 09:41
-
-
Save wizard1066/befe0d83e5eda19e78fd48aace146b69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State var image:UIImage! | |
var body: some View { | |
if image == nil { | |
TextView() | |
.onTapGesture { | |
image = TextView().snapshot() | |
let fileManager = FileManager.default | |
let cacheDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first | |
let url = cacheDirectory?.appendingPathComponent("file.png") | |
let path = url!.path | |
print("url \(url)") | |
if let data = image.jpegData(compressionQuality: 1.0) { | |
try? data.write(to: url!) | |
} | |
} | |
} | |
if image != nil { | |
Image(uiImage: image) | |
} | |
} | |
} | |
struct TextView: View { | |
var body: some View { | |
Text("6") { $0.tracking = CGFloat(10) } | |
.font(Font.custom("Neuton-Regular", size: 128)) | |
.frame(width:200, height: 200) | |
.background(Color.white) | |
.border(Color.black) | |
.ignoresSafeArea() | |
// .onTapGesture { | |
// for family in UIFont.familyNames { | |
// print(family) | |
// | |
// for names in UIFont.fontNames(forFamilyName: family){ | |
// print("== \(names)") | |
// } | |
// } | |
// } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment