Post

Replies

Boosts

Views

Activity

Reply to How to change TabView background color with SwiftUI?
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
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to SwiftUI Rerun animation when property changes.
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 } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21