HomeiOS Developmentios - Freeze animation when keyboard seems SwiftUI

ios – Freeze animation when keyboard seems SwiftUI


We now have Rectangle and TextField on display screen. When view seems we animate Rectangle offset. When faucet on TextField and keyboard seems on this second the animation begin little freezy.
Learn how to forestall this freezy behaviour ?

This concern occurs on simulator and machine. Xcode 15.1, Swift model 5.9.2.

Right here is straightforward code snippet to breed my concern.

import SwiftUI

struct ContentView: View {
    @State personal var offset: CGFloat = 0
    @State personal var enter = ""
    
    var physique: some View {
        VStack(alignment: .main) {
            Rectangle()
                .fill(Coloration.purple)
                .body(width: 100, top: 100)
                .offset(x: offset)
                .padding()
            Spacer()
            TextField("Title", textual content: $enter)
            Spacer()
        }
        .animation(.easeIn(length: 5).repeatForever(autoreverses: true), worth: offset)
        .onAppear(carry out: {
            offset = 200
        })
    }
}

Somebody is aware of the best way to repair this concern?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments