@interface ImproveInformationVC ()<UITextFieldDelegate>//輸入框代理動畫
@property (weak, nonatomic) IBOutlet RootTextField *userNameLabel;atom
@property (weak, nonatomic) IBOutlet RootTextField *contentLabel;spa
@property (weak, nonatomic) IBOutlet RootButton *nextBtn;代理
@property (weak, nonatomic) IBOutlet UIButton *maleBtn;orm
@property (weak, nonatomic) IBOutlet UIButton *femaleBtn;animation
@endit
@implementation ImproveInformationVCio
- (void)viewDidLoad {form
[super viewDidLoad];class
// Do any additional setup after loading the view.
self.userNameLabel.delegate = self;//設置代理
self.contentLabel.delegate = self;//設置代理
[self initview];
}
//開始編輯時 視圖上移 若是輸入框不被鍵盤遮擋則不上移。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
CGFloat rects = self.view.frame.size.height - (textField.frame.origin.y + textField.frame.size.height + 216 +50);
NSLog(@"aa%f",rects);
if (rects <= 0) {
[UIView animateWithDuration:0.3 animations:^{
CGRect frame = self.view.frame;
frame.origin.y = rects;
self.view.frame = frame;
}];
}
return YES;
}
//結束編輯時鍵盤下去 視圖下移動畫
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField{
[UIView animateWithDuration:0.3 animations:^{
CGRect frame = self.view.frame;
frame.origin.y = 0.0;
self.view.frame = frame;
}];
return YES;
}