So i have this function to move the TextField in ScrollView but the problem is some TextField on top sometimes move too far when the keyboard is presented
Here is my code :
 func textFieldDidBeginEditing(_ textField: UITextField) {
        moveTextFIeld(textField: textField, moveDistance: -20, up: true)
    }
    func textFieldDidEndEditing(_ textField: UITextField) {
        moveTextFIeld(textField: textField, moveDistance: -20, up: false)
    }
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        tanggalLahirTextField.resignFirstResponder()
}
    func moveTextFIeld(textField:UITextField,moveDistance:Int,up:Bool){
        let moveDuration = 0.3
        let movement : CGFloat = CGFloat(up ? moveDistance : -moveDistance)
        UIView.beginAnimations("animateTextField", context: nil)
        UIView.setAnimationBeginsFromCurrentState(true)
        UIView.setAnimationDuration(moveDuration)
        self.view.frame = self.view.frame.offsetBy(dx: 0, dy: movement)
//        self.view.frame=CGRect.offsetBy(self.view.frame,0,movement)
        UIView.commitAnimations()
    }
 
     
    