iOS中的UIKeyboard键盘视图使用方法小结

2020-01-15 16:34:52王旭

      CGRect frame = self.view.frame;  
      frame.origin.y -=216;  
      frame.size.height +=216;  
      self.view.frame = frame;  
       [UIView beginAnimations:@"ResizeView" context:nil];  
       [UIView setAnimationDuration:animationDuration];  
       self.view.frame = frame;                  
       [UIView commitAnimations];                  
}  
复制代码
- (BOOL)textFieldShouldReturn:(UITextField *)textField   
{//当用户按下ruturn,把焦点从textField移开那么键盘就会消失了  
        NSTimeInterval animationDuration = 0.30f;  
        CGRect frame = self.view.frame;      
        frame.origin.y +=216;        
        frame.size. height -=216;     
        self.view.frame = frame;  
    //self.view移回原位置    
    [UIView beginAnimations:@"ResizeView" context:nil];  
    [UIView setAnimationDuration:animationDuration];  
        self.view.frame = frame;                  
        [UIView commitAnimations];  
        [textField resignFirstResponder];     
}         

注:相关教程知识阅读请移步到IOS开发频道。