#import "ViewController.h"

@interface ViewController (){
    CALayer *_l1;//定义能够全局使用
    CALayer *_l2;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

CALayer *l2 = [CALayer layer];
    l2.frame = CGRectMake(50, 50, 100, 100);
    l2.backgroundColor = [UIColor greenColor].CGColor;
//    l2.transform = CATransform3DMakeRotation(M_PI_4, 1, 1, 0);//旋转
    [self.view.layer addSublayer:l2];
    _l2 = l2;
    
    
    CALayer *l1 = [CALayer layer];//创建并初始化
    l1.frame = CGRectMake(50, 50, 100, 100);
    l1.backgroundColor = [UIColor yellowColor].CGColor;//背景颜色
    //    l1.doubleSided = NO;   //是否两面
    //    l1.transform = CATransform3DMakeRotation(M_PI_4, 1, 1, 0);//旋转
    l1.cornerRadius = 30;//当要是一个矩形时 这个为将要在四个角变成圆角  如果有图片则不能直接显示效果
    l1.masksToBounds = NO;//这就是有图片时将会把多出的部分强行剪切,就能显示圆角
    l1.contents = (__bridge id)(([UIImage imageNamed:@"1.jpg"].CGImage));//添加图片
    l1.borderColor = [UIColor redColor].CGColor;//边框颜色
    l1.borderWidth = 10;//边框的大小
    l1.opacity = 1;//透明度
    l1.shadowColor = [UIColor blackColor].CGColor;//阴影颜色
    l1.shadowOpacity = 1;//阴影透明度
    l1.shadowOffset = CGSizeMake(10, 10);
    l1.shadowRadius = 6;//半径区域大小

[self.view.layer addSublayer:l1];//在页面上显示效果
    _l1 = l1;

}
- (IBAction)didClicked:(id)sender {
//    _l1.bounds = CGRectMake(0, 0, 100, 100);
//    _l1.position = CGPointMake(0, 0);//中心点到坐标显示
//    _l1.anchorPoint = CGPointMake(0, 1);//锚点
    _l1.zPosition = 100;//在Z轴上方
    _l1.doubleSided = NO;//反面无
    _l1.transform = CATransform3DMakeRotation(M_PI, 1, 0, 0);//旋转
    _l2.transform = CATransform3DIdentity;
    
}
- (IBAction)didClicked2:(id)sender {
    _l2.transform = CATransform3DMakeRotation(M_PI, 1, 0, 0);
    _l1.transform = CATransform3DIdentity;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

ios layer 动画的更多相关文章

  1. ios layer 动画-(transform.rotation篇)

    x轴旋转: CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"tra ...

  2. IOS UIVIEW layer动画 总结(转)

    转发自:http://www.aichengxu.com/article/%CF%B5%CD%B3%D3%C5%BB%AF/16306_12.html   IOS UIVIEW layer动画 总结, ...

  3. ios中layer动画和UIView动画代码总结

    kCATransitionFade淡出  kCATransitionMoveIn覆盖原图  kCATransitionPush推出  kCATransitionReveal底部显出来    pageC ...

  4. iOS核心动画学习整理

    最近利用业余时间终于把iOS核心动画高级技巧(https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html)看完,对应其中一 ...

  5. IOS 核心动画之CAKeyframeAnimation - iBaby

    - IOS 核心动画之CAKeyframeAnimation - 简单介绍 是CApropertyAnimation的子类,跟CABasicAnimation的区别是:CABasicAnimation ...

  6. iOS各种动画效果

    ios各种动画效果 最普通动画: //开始动画 [UIView beginAnimations:nil context:nil];  //设定动画持续时间 [UIView setAnimationDu ...

  7. IOS之动画

    IOS之动画   15.1 动画介绍 15.2 Core Animation基础 15.3 隐式动画 15.4 显式动画 15.5 关键帧显式动画 15.6 UIView级别动画 15.1 动画介绍 ...

  8. IOS 动画专题 --iOS核心动画

    iOS开发系列--让你的应用“动”起来 --iOS核心动画 概览 通过核心动画创建基础动画.关键帧动画.动画组.转场动画,如何通过UIView的装饰方法对这些动画操作进行简化等.在今天的文章里您可以看 ...

  9. ios 学习动画的套路 (一)

    你也肯定喜欢炫酷的动画! 在APP中,动画就是一个点睛之笔!可以给用户增加一些独特的体验感,估计也有许多的和我一样的,看着那些觉得不错的动画,也就只能流口水的孩子,毕竟~不知道从哪里下手去写!会连续的 ...

随机推荐

  1. 二十六、oracle pl/sql 分页

    一.无返回值的存储过程 古人云:欲速则不达,为了让大家伙比较容易接受分页过程编写,我还是从简单到复杂,循序渐进的给大家讲解.首先是掌握最简单的存储过程,无返回值的存储过程. 案例:现有一张表book, ...

  2. PHP来实现文件上传

    文件php <?phpif ($_FILES["file"]["error"] > 0){ echo '错误: ' . $_FILES[" ...

  3. Arduino使用注意问题及编程相关

    1.Arduino的概念 arduino是一款便捷灵活方便上手的开源电子原型平台,包含硬件(各种型号的arduino板)和软件(arduino IDE), 是一个基于开放原始码的软硬件平台,构建于开放 ...

  4. scp免密码传送文件

    一.单向 ssh-keygen -t rsa 单向无密码访问远程服务器操作比较简单,比如服务器A需要无密码访问服务器B(A–>B),那么只需要在服务器A生成密钥对,将生成的公钥上传到服务器B的相 ...

  5. MITMF

    一. 安装 项目地址:https://github.com/byt3bl33d3r/MITMf 需要自行手动安装python-nfqueue,pefile模块 sudo apt-get install ...

  6. android基础(一)

    wrap_conten:包裹实际文本内容 match_parent:当前控件铺满父类容器:2.3api之后添加的一个属性值 fill_parent:包裹实际文本内容,在2.3api之前的一个属性值 a ...

  7. 浙大pat 1054 题解

    1054. The Dominant Color (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Behind the scen ...

  8. Java常用集合类(1)

    一.HashMap 参考文章: http://yikun.github.io/2015/04/01/Java-HashMap%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E ...

  9. PHP7新功能及语法变化总结

    1.标量类型声明有两种模式: 强制 (默认) 和 严格模式. 现在可以使用下列类型参数(无论用强制模式还是严格模式): 字符串(string), 整数 (int), 浮点数 (float), 以及布尔 ...

  10. GetLastError() 返回值含义

    [0]-操作成功完成.[1]-功能错误.[2]-系统找不到指定的文件.[3]-系统找不到指定的路径.[4]-系统无法打开文件.[5]-拒绝访问.[6]-句柄无效.[7]-存储控制块被损坏.[8]-存储 ...