iOS 7 - Keyboard animation

后端 未结 8 1593
广开言路
广开言路 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:31

    In iOS 13 you are in an implicit animation, so just modify your layout inside your notification handler and it will animate with the correct duration and curve.

    0 讨论(0)
  • 2020-12-02 10:41

    To use the same animation as keyboard has, you have to use undocumented Curve option.

    - (void)keyboardWillHide:(NSNotification *)notification {
        NSDictionary *userInfo = [notification userInfo];
    
        CGRect rect = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
        NSTimeInterval animationDuration = [[userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
        NSInteger curve = [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue] << 16;
    
        [UIView animateWithDuration:animationDuration delay:0.0 options:curve animations:^{
    
        } completion:nil];
    }
    

    I found that actually method animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion: is the new way that all animations are done in iOS7 and iOS8 now. You just make right duration, damping and velocity and you will get the same effect, but even you can change speed/time.

    0 讨论(0)
提交回复
热议问题