I'm animating the progress of a bar (below), I have it embedded inside 2 parent views: parent 1 and parent 2. Both parent views are tabs in a TabView. When the app loads the animation in parent view 1 is as expected, but when tapping on the tab to navigate to parent view 2, the bar seems to fly in from the bottom left of the screen? 🤔
struct BarView: View { var progress: Double = 0.0 var progressAnimation: Animation { Animation .linear .speed(0.5) .delay(0.5) } var body: some View { ZStack { ZStack(alignment: .leading) { RoundedRectangle(cornerRadius: 12.0) .fill(Color(.lightGray)) .opacity(0.1) .frame(height: 15) .overlay(GeometryReader { geometry in RoundedRectangle(cornerRadius: 12.0) .fill(getColorForBar(progress: progress)) .frame(width: getFillWidth(progress: progress, geometry: geometry), height: 15) .animation(self.progressAnimation) }, alignment: .leading) } } } https://stackoverflow.com/questions/65948230/swiftui-strange-animation-behavior-inside-a-tabview January 29, 2021 at 11:03AM
没有评论:
发表评论