iOS动画和特效(三)MotionEffects
来源:互联网 发布:求生之路2游侠网络联机 编辑:程序博客网 时间:2024/05/16 23:02
核心原理
UIInterpolatingMotionEffect 是 UIMotionEffect的一个子类,是具体的实现类,实现设备水平角度变化对UI元素的属性
UIImageView *imView =[UIImageView new]; imView.frame = CGRectMake(100, 100, 200, 200); imView.image = [UIImage imageNamed:@"1"]; [self.view addSubview:imView]; UIInterpolatingMotionEffect *xeffect =[[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; xeffect.minimumRelativeValue = [NSNumber numberWithDouble:10.0]; xeffect.maximumRelativeValue = [NSNumber numberWithDouble:50.0];; UIInterpolatingMotionEffect *yeffect = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; yeffect.minimumRelativeValue = [NSNumber numberWithDouble:10.0]; yeffect.maximumRelativeValue = [NSNumber numberWithDouble:80.0]; UIMotionEffectGroup *ffectGroup = [[UIMotionEffectGroup alloc]init]; ffectGroup.motionEffects = @[xeffect,yeffect]; [imView addMotionEffect:ffectGroup];ui元素绑定效果后,设备水平角度改变,就会对应修改keyPath的value,这里指定的keyPath是中心坐标的x位置,所以会水平移动。
0 0
- iOS动画和特效(三)MotionEffects
- iOS动画和特效(三)MotionEffects
- iOS-MotionEffects
- iOS动画和特效(一)UIView动画和CoreAnimation
- iOS动画和特效(一)UIView动画和CoreAnimation
- cocos2d-x动作、特效和动画(三)扭曲动作
- iOS动画和特效(二)UIKit力学行为
- iOS动画和特效(二)UIKit力学行为
- iOS swift动画和特效专题
- 动画特效三:搜索动画
- iOS 动画特效
- iOS动画特效
- iOS-各种动画特效
- cocos2d-x动作、特效和动画(三)旋转和跳跃动作
- iOS动画和特效(四)controller间的自定义过渡效果
- iOS动画和特效(四)controller间的自定义过渡效果
- JQuery动画和特效
- JQ动画和特效轮播图
- Gradle多渠道打包
- iptables学习概要总结
- ssdb下载安装
- Ubnutu忘记用户密码怎么办
- hdoj 5533 Dancing Stars on Me【数学】
- iOS动画和特效(三)MotionEffects
- Python中的__main__
- Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set——【hibernate 日常错误】
- 底层_读取文件时上锁_demo
- thinkphp3.2 控制器
- vim 正则表达式
- Java源码 SpringMVC Mybatis Shiro Bootstrap Rest Webservice
- MyEclipse代码提示设置
- 68,自定义代码生成快捷键