zoukankan      html  css  js  c++  java
  • 核心动画-04-CALayer隐式动画

     1 //
     2 //  ViewController.m
     3 //  04 CALayer的隐式动画
     4 //
     5 //  Created by ZhuJiaCong on 16/4/18.
     6 //  Copyright © 2016年 wxhl. All rights reserved.
     7 //
     8 
     9 #import "ViewController.h"
    10 
    11 @interface ViewController ()
    12 {
    13     CALayer *_layer;
    14 }
    15 @end
    16 
    17 @implementation ViewController
    18 
    19 - (void)viewDidLoad {
    20     [super viewDidLoad];
    21     
    22     //只有Layer不是View的根Layer时,才能使用隐式动画
    23     // self.view.layer
    24     
    25     //创建一个Layer
    26     _layer = [CALayer layer];
    27     _layer.backgroundColor = [UIColor redColor].CGColor;
    28     _layer.bounds = CGRectMake(0, 0, 100, 100);
    29     _layer.position = self.view.center;
    30     
    31     
    32     _layer.borderColor = [UIColor orangeColor].CGColor;
    33     _layer.borderWidth = 5;
    34     
    35     
    36     [self.view.layer addSublayer:_layer];
    37     
    38     
    39     
    40 }
    41 
    42 
    43 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    44     
    45     //隐式动画
    46     //当我们在设置Layer的某些属性时,系统会自动的给Layer添加动画
    47     //动画的实现代码是在系统底层,无法对动画的配置进行修改
    48 //    _layer.transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
    49     
    50     UITouch *touch = [touches anyObject];
    51     CGPoint location = [touch locationInView:self.view];
    52     _layer.position = location;
    53     
    54     
    55     //查找文档 可以获取所有支持隐式动画的属性
    56     //查找关键词 CALayer Animatable Properties
    57     _layer.backgroundColor = [UIColor greenColor].CGColor;
    58     //不透明度
    59     _layer.opacity = 1;
    60     _layer.borderColor = [UIColor purpleColor].CGColor;
    61     _layer.borderWidth = 20;
    62 }
    63 
    64 - (void)didReceiveMemoryWarning {
    65     [super didReceiveMemoryWarning];
    66     // Dispose of any resources that can be recreated.
    67 }
    68 
    69 @end
    时光见证了成长,还很无知,我想一点点幼稚转为有知!
  • 相关阅读:
    面试准备
    论文投稿Cover letter
    Pycharm 快捷键
    linux下常用命令:
    Qt中数据模块学习
    Qt 多线程和网络编程学习
    VS高效开发快捷键
    良好编码风格习惯整理
    Qt QAxObject操作excel文件过程总结(转):
    Qt开发中的实用笔记三--关于各种类的零碎知识点:
  • 原文地址:https://www.cnblogs.com/foreveriOS/p/5407191.html
Copyright © 2011-2022 走看看