Вот мой код:
Код: Выделить всё
struct TextAnimationView: View {
@State private var textValue = "Hello"
var body: some View {
VStack(spacing: 50) {
Text(textValue)
.font(.largeTitle)
.frame(width: 200, height: 200)
.id("MyText" + textValue)
.transition(.opacity)
.animation(.easeInOut(duration: 1.0), value: textValue)
Button("Change Text") {
textValue = textValue == "Hello" ? "World" : "Hello"
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -text-cont
Мобильная версия