Using Text Animation With SwiftUI 4
With SwiftUI 4, we can now reflect text features such as color change and font change to the user in the form of an animated transition.
We do it like this:
struct TextAnimationExample: View {
@State private var changeStyle: Bool = false
var body: some View {
Text("Hello, World!")
.font(.system(size: 30))
.fontWeight(changeStyle ? .heavy : .medium)
.onTapGesture {
withAnimation {
changeStyle.toggle()
}
}
}
}
Have you used the code? You can explain in the comments.
Post Comment