Why does the size animate and not the text with this SwiftUI view?

社会主义新天地 提交于 2021-01-05 07:10:13

问题


Why does the size animate and not the text with this SwiftUI view? The Text correctly gets bigger and smaller, but the value of the text does not change.

struct ContentView: View {
    @State private var isAnimating = 0

        var foreverAnimation: Animation {
            Animation.linear(duration: 1)
            .repeatForever()
        }

        var body: some View {

            Text(isAnimating > 5 ? "Hello" : "Byebye")
                .scaleEffect(isAnimating > 5 ? 1.5 : 1)
                .animation(foreverAnimation)
                .onAppear {
                    self.isAnimating = 10
            }
    }
}

来源:https://stackoverflow.com/questions/65282145/why-does-the-size-animate-and-not-the-text-with-this-swiftui-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!