如何使用默认的iOS7 UIAnimation曲线 [英] How to use the default iOS7 UIAnimation curve

查看:115
本文介绍了如何使用默认的iOS7 UIAnimation曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

iOS7 animations don't behave the same way as in iOS6. They appear to use a different bezier curve. Where iOS6 uses a kind of "easeInOutSine" curve, iOS7 is more of the "easeInOutExpo" kind. (http://matthewlein.com/ceaser/)

是否有使用该曲线的方法?我想在键盘打开/关闭时同步动画.

Is there a way to use that curve? I want to sync my animations when the keyboard opens/closes.

推荐答案

这里是我的操作方式(至少在要显示键盘时)

Here's how I do it (at least when the keyboard is about to be shown)

- (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];
}

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

You get the animation curve from the keyboard notification as usual and translate it to an animation option by bit-shifting it.

这篇关于如何使用默认的iOS7 UIAnimation曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆