. Using Text Animation With SwiftUI 4 – iappstop-Today's Technology

Using Text Animation With SwiftUI 4

Using Text Animation With SwiftUI 4

swiftui 4 toggle animation

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