- - (void) animateTextField: (UITextField*) textField up: (BOOL) up{
- int txtPosition = (textField.frame.origin.y - 140);
- const int movementDistance = (txtPosition < 0 ? 0 : txtPosition); // tweak as needed
- const float movementDuration = 0.3f; // tweak as needed
- int movement = (up ? -movementDistance : movementDistance);
- [UIView beginAnimations: @"anim" context: nil];
- [UIView setAnimationBeginsFromCurrentState: YES];
- [UIView setAnimationDuration: movementDuration];
- self.view.frame = CGRectOffset(self.view.frame, 0, movement);
- [UIView commitAnimations];
- }
- - (void)textFieldDidBeginEditing:(UITextField *)textField{
- [self animateTextField: textField up: YES];
- }
- - (void)textFieldDidEndEditing:(UITextField *)textField{
- [self animateTextField: textField up: NO];
- }
- - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
- [theTextField resignFirstResponder];
- return YES;
- }
'iOS' 카테고리의 다른 글
iOS - OTA ( Over the Air AdHoc ) (1) | 2012.10.04 |
---|---|
UITextField 키보드 간단하게 내리기 (0) | 2012.10.04 |
iOS5의 Twitter.framework를 이용하여 Twitter에 메세지 업데이트하기(1) (0) | 2012.09.26 |
키보드 리턴키 타입 변경 (0) | 2012.09.24 |
앱 정보 가져오기 (앱이름, 버전) (0) | 2012.09.22 |