1、UIMotionEffect简介

  在iOS7.0推出了UIMotionEffect运动视觉效果,就是从屏幕偏移不同角度、看到的效果不同!

NS_CLASS_AVAILABLE_IOS(7_0)
@interface UIMotionEffect : NSObject <NSCopying, NSCoding>
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
//观察者的角度偏移viewerOffset,获取运动视觉效果的各项属性和值
- (nullable NSDictionary<NSString *, id> *)keyPathsAndRelativeValuesForViewerOffset:(UIOffset)viewerOffset;
@end typedef NS_ENUM(NSInteger, UIInterpolatingMotionEffectType) {
UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis,//X轴
UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis//Y轴
}; @interface UIInterpolatingMotionEffect : UIMotionEffect
- (instancetype)initWithKeyPath:(NSString *)keyPath type:(UIInterpolatingMotionEffectType)type NS_DESIGNATED_INITIALIZER;//初始化
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; @property (readonly, nonatomic) NSString *keyPath;//获取角度偏移
@property (readonly, nonatomic) UIInterpolatingMotionEffectType type;//获取类型
@property (nullable, strong, nonatomic) id minimumRelativeValue;//最小角度偏移
@property (nullable, strong, nonatomic) id maximumRelativeValue;//最大角度偏移
@end @interface UIMotionEffectGroup : UIMotionEffect
@property (nullable, copy, nonatomic) NSArray<__kindof UIMotionEffect *> *motionEffects;//添加水平和垂直效果添加到对应UI上
@end

2、简单使用

- (void)addEffectWithOffset:(NSInteger)offset withView:(UIView *)view{
UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
effectX.minimumRelativeValue = @(-offset);
effectX.maximumRelativeValue = @(offset); UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
effectY.minimumRelativeValue = @(-offset/);
effectY.maximumRelativeValue = @(offset/); // UIMotionEffectGroup *group = [[UIMotionEffectGroup alloc] init];
// group.motionEffects = @[effectX,effectY];
view.motionEffects = @[effectX,effectY];
}

最新文章

  1. having过滤语句
  2. hibernate(七) hibernate中查询方式详解
  3. 深入理解Java:注解(Annotation)自定义注解入门
  4. ios swfit 由继承UIButton了解类的构造方法
  5. scp不可用:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
  6. mycat初探
  7. VS2012下安装NuGet
  8. extjs文件上传
  9. IDEA SDK(Software Development Kit) 介绍
  10. 南理第八届校赛同步赛-F sequence//贪心算法&amp;二分查找优化
  11. Sonar入门(四):Eclipse集成Sonar
  12. WebStorm重复代码快捷表达
  13. codeblock字体问题
  14. linux之dos2unix命令
  15. HTML&amp;javaSkcript&amp;CSS&amp;jQuery&amp;ajax(三)
  16. SQL 分隔字符串
  17. 物联网架构成长之路(10)-Nginx负载均衡
  18. ionic 监听页面滚动,点击停止滚动
  19. innodb compressed 表碰到的问题,BUG么?
  20. libcurl.dll 7.60.0静态库包含openssl/zlib

热门文章

  1. windows下安装jenkins初级(1)
  2. 【JZOJ6285】飘雪圣域
  3. jQuery-介绍 加载 选择器 样式操作 属性操作 绑定click事件
  4. PHP FTP 常量
  5. 【历年真题】斐波那契数列logn做法
  6. web前端开发2018年12月找工作总结
  7. hive的数据压缩
  8. inobounce.js : 禁止IOS H5的滑动回弹
  9. sublime 分屏 实现代码整体前后移
  10. spring boot+vue.js发送post时一直415,swagger却很正常