iOS 7 - Keyboard animation

后端 未结 8 1620
广开言路
广开言路 2020-12-02 09:51

I\'m trying to understand the new keyboard animation in iOS 7.0 on the iPhone 5 Simulator. I want to resize my UITableView when the keyboard appears, but I can\

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 10:29

    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

提交回复
热议问题