Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created November 9, 2022 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wizard1066/befe0d83e5eda19e78fd48aace146b69 to your computer and use it in GitHub Desktop.
Save wizard1066/befe0d83e5eda19e78fd48aace146b69 to your computer and use it in GitHub Desktop.
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