jasu's blog
블로그 메뉴글
becomeFirstResponder, resignFirstResponder 애니메이션 duration time 설정
Programming/Objective-C
2012. 7. 22. 04:48
UITextField 를 터치하면 나타나거나 사라지는 keypad의 애니메이션 속도를 조정하기 위해서는 아래와 같은 방법을 사용할 수 있다.
[UIView animateWithDuration:0.3 animations:^{ [inputText becomeFirstResponder]; }]; [UIView animateWithDuration:0.3 animations:^{ [inputText resignFirstResponder]; }];
애니메이션 종료 시점에 처리해야하는 부분이 있으면 간단하게 아래와 같이 처리할 수도 있다. (delegate 메소드를 사용하는 것을 권장.)
[UIView animateWithDuration:0.3 animations:^{ [inputText becomeFirstResponder]; } completion:^(BOOL finished) { // 애니메이션 종료후 처리 }];
애니메이션 없이 바로 나타나게 하려면 UIView animate duration time을 0으로 설정하면 된다.