I want to perform some animation on secondTextField when the FirstTextfield becomesFirstResponder
After resign first responder the animation should reverse back in second text field. How can I achieve this in swift?
Note: It is different from moving textfield to the top on keyboard appears.
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
if(textField == firstTextField) {
UIView.animateWithDuration(1.0, animations: {
self.secTextField.frame = CGRectMake(self.secTextField.frame.origin.x + 500, self.secTextField.frame.origin.y, self.secTextField.frame.size.width, self.secTextField.frame.size.height) })
}
return true
}
What I want to do is, when the user types in firstTextField, the secTextField should go and hide out of sight. What actually happens is the secTextField comes from out of sight to its original position
I finally found the answer. I did the following steps.
Then the coding:
`self.secTextField.frame.origin.x = self.secTextField.frame.origin.x + 500`