Post

Replies

Boosts

Views

Activity

Reply to SwiftUI: How to blend between UIImages without pulsating/pumping effect?
There is no problem with the phase animator. If I do this struct ContentView: View { @State var img1 = UIImage(systemName: "gear")! @State var img2 = UIImage(systemName: "gear")! var body: some View { PhaseAnimator([1, 2]) { phase in Image(uiImage: phase == 1 ? img1 : img2) .renderingMode(.template) .foregroundStyle(.white) .background(.black) } } } It exactly does blend as expected. It blends two images (with identical content) and you will not see a pumping effect. The problem starts, when I create an UIImage with UIGraphicsBeginImageContext like with the resize function in my first post. Then the two identical images are pulsating. PhaseAnimator([1, 2]) { phase in Image(uiImage: phase == 1 ? img1 : img2) .renderingMode(.template) .foregroundStyle(.white) .background(.black) } .task { img1 = self.resizeImage(image: img1, newWidth: widgetSize) img2 = self.resizeImage(image: img2, newWidth: widgetSize) } (And yes, UIGraphicsBeginImageContext is deprecated, but it does not matter, the same behaviour can be observed using UIGraphicsImageRenderer)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’24
Reply to SwiftUI: How to blend between UIImages without pulsating/pumping effect?
There is no problem with the phase animator. If I do this struct ContentView: View { @State var img1 = UIImage(systemName: "gear")! @State var img2 = UIImage(systemName: "gear")! var body: some View { PhaseAnimator([1, 2]) { phase in Image(uiImage: phase == 1 ? img1 : img2) .renderingMode(.template) .foregroundStyle(.white) .background(.black) } } } It exactly does blend as expected. It blends two images (with identical content) and you will not see a pumping effect. The problem starts, when I create an UIImage with UIGraphicsBeginImageContext like with the resize function in my first post. Then the two identical images are pulsating. PhaseAnimator([1, 2]) { phase in Image(uiImage: phase == 1 ? img1 : img2) .renderingMode(.template) .foregroundStyle(.white) .background(.black) } .task { img1 = self.resizeImage(image: img1, newWidth: widgetSize) img2 = self.resizeImage(image: img2, newWidth: widgetSize) } (And yes, UIGraphicsBeginImageContext is deprecated, but it does not matter, the same behaviour can be observed using UIGraphicsImageRenderer)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to SwiftData/DataUtilities.swift:1093: Fatal error: Unable to parse keypath for non-PersistentModel Type
The Xcode Cloud TestFlight Build setting was set to "Latest Release or Beta" and Apple had updated its tool chain to Xcode 15.3 beta 2 (15E5188]) Switching back to Xcode 15.2 (15C500b) solved it.
Replies
Boosts
Views
Activity
Feb ’24