Post

Replies

Boosts

Views

Activity

ImageRenderer on iOS - generates blurry image, .scale ineffective?
I'm getting a low quality image when using ImageRenderer on iOS16 both on simulator and device. i.e. when saving the rendered image to the Photo Library or sending to Notes.. it's very pixelated. Everything I read would suggest simply setting .scale but that appears to have no effect. I'm including a sample project. You can see the commented out sections which also fail. It would seem that scale is being ignored completely. Has anyone else experienced this? struct helloWorldView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") } } } struct ContentView: View { @State private var screenshotimage: UIImage? @State private var screenshot: Bool = false @State private var showsharesheet: Bool = false @State private var sharescreenshot: Bool = false @State private var imageToShare: Image? var body: some View { NavigationStack { helloWorldView() .padding() .toolbar { ToolbarItem(placement: .primaryAction) { Button("Share") { showsharesheet.toggle() } } } .sheet(isPresented: self.$showsharesheet) { NavigationStack { ScrollView { Section { if screenshotimage != nil { Image(uiImage: screenshotimage!) ShareLink( item: Image(uiImage: screenshotimage!), preview: SharePreview( "Share Title", image: Image(uiImage: screenshotimage!) ) ) { Label("Share Image", systemImage: "square.and.arrow.up") .foregroundColor(.white) .padding() .background(.blue.gradient.shadow(.drop(radius: 1, x: 2, y: 2)), in: RoundedRectangle(cornerRadius: 5)) } } else { Text("Creating image..") } } } .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Dismiss") { showsharesheet = false } } } .navigationTitle("Preview") .navigationBarTitleDisplayMode(.inline) } .onAppear() { screenshot.toggle() } .onChange(of: screenshot, perform: { _ in // Task { let renderer = ImageRenderer(content:helloWorldView()) // renderer.scale = UIScreen.main.scale renderer.scale = 3.0 screenshotimage = renderer.uiImage // } }) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
4
3
2.8k
Oct ’22
Why? "CloudKit integration does not support unique constraints"
Hi, On iOS 14 beta 1-3 I was happily using a constraint on several entities in NSPersistentCloudKitContainer. The part of the app using this was essentially an RSS reader - two different devices were independently fetching news and no duplicates due to the constraints. Now on iOS14 beta 4 I'm receiving "CloudKit integration does not support unique constraints", which means I've had to remove the constraints.. Now the app is subject to CloudKit sync vs RSS import timing issues.. if CloudKit syncs after the RSS import then there are "duplicate" items. What's the "workaround" for this please? It really should just work. Thanks, Andy
6
0
4.1k
Aug ’20