iOS 7 - Keyboard animation

后端 未结 8 1607
广开言路
广开言路 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条回答
  •  Happy的楠姐
    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.

提交回复
热议问题