MotionBlur
允许您向动画添加运动模糊效果(目前仅支持位置的更改)。请参阅随附的博客文章了解其实现方式。(链接至文章)
注意,当菜单滑动进出时,文字和图标会变得模糊。
首先,使用以下方式导入:
#import "UIView+MotionBlur.h"
然后使用它:
[yourView enableBlurWithAngle:M_PI_2 completion:^{
[UIView animateWithDuration:0.5
delay:0
usingSpringWithDamping:0.8
initialSpringVelocity:0.3
options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState
animations:^{
CGRect f = yourView.frame;
f.origin = CGPointMake(0, 300);
yourView.frame = f;
} completion:^(BOOL finished) {
[yourView disableBlur];
}];
}];
在动画之前计算快照和模糊,这就是为什么API是异步的。您还应查看示例项目和阅读头文件中的注释:Classes/UIView+MotionBlur.h
。
要运行示例项目;克隆仓库,并打开Example/MotionBlur.xcodeproj
。
Arkadiusz Holko