IOS学习之核心动画-倒影
2016-07-28 22:59
465 查看
这里我们还是使用哆啦A梦做素材,然后实现倒影效果:
打开xcode,创建项目,把图片添加到main.storyboard居中对其
自定义view改变它layer的属性
修改view的class
写代码
然后再修改:
即可达到效果
最后设置代码
效果图如下,我设置了背景颜色
打开xcode,创建项目,把图片添加到main.storyboard居中对其
自定义view改变它layer的属性
#import "VcView.h" @implementation VcView + (Class)layerClass { return [CAReplicatorLayer class]; } @end
修改view的class
写代码
#import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imgV; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CAReplicatorLayer *repL = (CAReplicatorLayer *)self.view.layer; repL.instanceCount = 2; //复制出来的自层都是绕着复制层的锚点进行旋转的 repL.instanceTransform = CATransform3DMakeRotation(M_PI, 1, 0, 0); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
然后再修改:
即可达到效果
最后设置代码
#import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imgV; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CAReplicatorLayer *repL = (CAReplicatorLayer *)self.view.layer; repL.instanceCount = 2; //复制出来的自层都是绕着复制层的锚点进行旋转的 repL.instanceTransform = CATransform3DMakeRotation(M_PI, 1, 0, 0); repL.instanceRedOffset -= 0.1; repL.instanceGreenOffset -= 0.1; repL.instanceBlueOffset -= 0.1; repL.instanceAlphaOffset -= 0.1; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
效果图如下,我设置了背景颜色
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- Gifski:一个跨平台的高质量 GIF 编码器
- 模仿动画的放大缩小容器
- jQuery 1.9.1源码分析系列(十五)动画处理之缓动动画核心Tween
- Android实现定制返回按钮动画效果的方法
- Android中ViewFlipper的使用及设置动画效果实例详解
- jQuery实现美观的多级动画效果菜单代码
- php判断GIF图片是否为动画的方法
- jQuery实现动画效果circle实例
- HTML5游戏引擎LTweenLite实现的超帅动画效果(附demo源码下载)
- 浅析JavaScript动画
- js排序动画模拟-插入排序
- javascript+HTML5的Canvas实现Lab单车动画效果
- 基于javascript实现漂亮的页面过渡动画效果附源码下载