- (void)viewDidLoad {
[super viewDidLoad];
// 创建图层
CALayer *layer = [CALayer layer];
layer.backgroundColor = [UIColor blueColor].CGColor;
// 设置frame
layer.frame = CGRectMake(100, 100, 100, 100);
// 添加到控制器view的图层上面
[self.view.layer addSublayer:layer];
self.layer = layer;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// self.layer.backgroundColor = [UIColor orangeColor].CGColor;
// self.layer.position = CGPointMake(300, 300);
//
// 开启事务
[CATransaction begin];
// 禁止隐式动画
[CATransaction setDisableActions:YES];
self.layer.bounds = CGRectMake(0, 0, 400, 400);
// 提交事务
[CATransaction commit];
}