美文网首页
键盘frame变化

键盘frame变化

作者: lltree | 来源:发表于2017-12-01 14:01 被阅读6次

    添加键盘的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);
       // }];
    }
    

    相关文章

      网友评论

          本文标题:键盘frame变化

          本文链接:https://www.haomeiwen.com/subject/yxfwbxtx.html