How to mimic Keyboard animation on iOS 7 to add “Done” button to numeric keyboard?

前端 未结 7 1041
故里飘歌
故里飘歌 2020-12-02 10:09

I had been doing something like this to mimic the keyboard animation on older version of iOS.

CGRect keyboardBeginFrame;
[[note.userInfo objectForKey:UIKeybo         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 10:55

    You can use animateWithDuration block and set curve inside it. It's clean and work well.

    UIViewAnimationCurve curve = [[notification.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];
    double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    
    [UIView animateWithDuration:duration
                        delay:0
                      options:UIViewAnimationOptionBeginFromCurrentState 
                   animations:^{
                     [UIView setAnimationCurve:curve];
                     /* ANIMATION HERE */
                     // don't forget layoutIfNeeded if you use autolayout
                   }
                   completion:nil];
    

    Happy coding!

    UPDATE

    You can use a simple UIViewController category written by me https://github.com/Just-/UIViewController-KeyboardAnimation

提交回复
热议问题