Ok ich habe herausgefunden das ich .jpegData() statt .pngData() verwenden sollte (man sieht in shortcuts das das mit /9j anfängt) aber jetzt weiß ich nicht welche compressionQuality ich brauche…Also welche compressionQuality Shortcuts verwendet…?
Post
Replies
Boosts
Views
Activity
You could use a variable that decides which view should be visible.
if visibleView == 1 {
MapUView
}
…
and than just change the variable with the button.But i think NavigationLinks are better…
I think following extension could do the work:
extension UIView {
func saveAsImage() -> UIImage {
let renderer = UIGraphicsImageRenderer(bounds: bounds)
let image = renderer.image { rendererContext in
layer.render(in: rendererContext.cgContext)
}
if let data = image.pngData() {
let filename = *file path*
try? data.write(to: filename)
}
}
}
you than just have to call the function(I never tried it…)
don’t forget to replace file path with the file path where you want to save the image.
So, I don’t think that comments work… idk why, I tried it 3rimes, but my comment is still missing…
So what I said was:
You could replace UIGraphicsImageRenderer(bounds: bounds) with UIGraphicsImageRenderer(bounds: *CGRect*) or UIGraphicsImageRenderer(frame: *CGSize*).
I think in both cases "*CGSize*" should change the image Size.