评论框 键盘升起 2021-08-15

2021-08-15  本文已影响0人  ZM_微笑向阳

1、键通知

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

2、键盘将要出现

-(void)keyboardWillChange:(NSNotification *)note {

      //获取键盘的高度
      CGFloat keyboardY = [[note.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y;
      CGFloat ty = keyboardY - KH;


      [UIView animateWithDuration:0.3 animations:^{
             self.bottomView.transform = CGAffineTransformMakeTranslation(0,ty);
      }];
}
上一篇下一篇

猜你喜欢

热点阅读