键盘frame变化

2017-12-01  本文已影响6人  lltree

添加键盘的frame变化的代理


 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];

#pragma  键盘开始弹出
//2015-08-18 17:10:42.768 02-01QQ聊天[7822:276845] NSConcreteNotification 0x7fa0f86137f0 {name = UIKeyboardDidChangeFrameNotification; userInfo = {
//    UIKeyboardAnimationCurveUserInfoKey = 7;
//    UIKeyboardAnimationDurationUserInfoKey = "0.25";
//    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 258}}";
//    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 796}";
//    UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 538}";
//    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 667}, {375, 258}}";
//    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 409}, {375, 258}}";
//}}
-(void) keyboardWillChangFrame:(NSNotification *)info
{
   // NSLog(@"%@",info);
    NSDictionary *dict=info.userInfo;
   // NSLog(@"%@",dict);
    
    CGFloat ty=[dict[UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y- 667;
    CGFloat duration=[dict[UIKeyboardAnimationDurationUserInfoKey] floatValue];
   // [UIView animateWithDuration:duration animations:^{
        self.view.transform=CGAffineTransformMakeTranslation(0, ty);
   // }];
}
上一篇下一篇

猜你喜欢

热点阅读