如何使用默认的iOS7 UIAnimation曲线

Mel*_*lls 19 core-animation objective-c uianimation ios

iOS7动画的行为与iOS6中的行为不同.它们似乎使用不同的贝塞尔曲线.iOS6使用一种"easeInOutSine"曲线,iOS7更像是"easeInOutExpo"类型.(http://matthewlein.com/ceaser/)

有没有办法使用那条曲线?我想在键盘打开/关闭时同步我的动画.

Abi*_*ern 39

这是我的方式(至少在键盘即将显示时)

- (void)keyboardWillShow:(NSNotification *)notification {
    NSDictionary *keyboardAnimationDetail = [notification userInfo];
    UIViewAnimationCurve animationCurve = [keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] integerValue];
    CGFloat duration = [keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] floatValue];

    [UIView animateWithDuration:duration delay:0.0 options:(animationCurve << 16) animations:^{
        // Set the new properties to be animated here
    } completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

您可以照常从键盘通知中获取动画曲线,并通过位移将其转换为动画选项.

  • 只需使用(7 << 16)作为animateWithDuration的选项. (3认同)