Thanks OOPer!
Turns out all I needed was to add the onChange you suggested - needing both the onAppear and onChange. So the BackgroundView looks like this:
swift
struct BackgroundView: View {
var status: String = "0"
@State private var isAnimating: Bool = false
var body: some View {
ZStack {
Group {
Image(systemName: "\(status).circle.fill")
.resizable()
.scaledToFit()
.frame(width: 220)
.foregroundColor(.red)
}
.scaleEffect(isAnimating ? 1.0 : 0, anchor: .top)
}
.animation(Animation.easeOut(duration: 0.4), value: isAnimating)
.onAppear(perform: {
print("appear: \(status)")
isAnimating = true
})
.onChange(of: status) { _ in
print("change: \(status)")
isAnimating = false
withAnimation(Animation.easeOut(duration: 0.4)) {
isAnimating = true
}
}
}
}
Post
Replies
Boosts
Views
Activity
This does work, however...
It seems to have a side effect of making a segmented picker inside the nav view unresponsive. (Oddly, a Toggle control does still work.)
Bug or feature I'm not sure.
I've tried the onTapGesture at different levels and also tried onDisappear, none of which resolved the issue.
xcode 12.4/iOS 14.1
Using onAppear did not work for me. I split the difference to get it to work for me, using
init() {
UITabBar.appearance().barTintColor = UIColor(Color(colorExtraLight)) // custom color.
}
Also, with backgroundColor it appeared to be about 50% opaque, but barTintColor appeared solid.
xcode 12.4/iOS 14.0
I was getting this error as well. (The run destination iPhone 12 Pro Max is not valid...)
What resolved it was going into the Simulator setup window and deleting the paired watches from all the iOS simulators I was not using (such as iPhone 12 Pro Max).
I downloaded the latest Xcode beta 12.2 and ran with iOS14.2 simulator and don't see the issue.
Thanks for checking.
I'm not changing the opacity, that's why it being opaque is my issue.
When a button is tapped, it automatically dims (becomes opaque) until the tap is released. In my (red circle) example, after releasing the tap it is remaining dim/opaque. For the blue square in my example, the text itself does this dimming/undimming when tapped and released.