Здесь возможен подход (протестировано и работает с Xcode 11.2 / iOS 13.2)
Примечание: предварительный просмотр плох при обработке переходов, поэтому тестируйте либо с помощью симулятора, либо с реальным устройством.
struct ContentView: View {
@State var showText: Bool = false
var body: some View {
VStack() {
Spacer()
Image(systemName: "star.fill")
if self.showText {
// Changing selection value.
Text("Favorites")
.font(.custom("Helvetica Neue", size: 20))
.transition(.opacity) // << transition works in add/remove view
}
Spacer()
.frame(height: 50)
Button(action: {
withAnimation(Animation.easeOut(duration: 2.0).delay(0.5)) {
self.showText.toggle() // << transition requires explicit animation
}
}) {
Text("Toggle Text")
}
Spacer()
}
.padding(5)
.font(.custom("Helvetica Neue", size: 14))
}
}