CALayer创建和和如何隐藏隐式动画

//修改CALay属性会产生隐式动画

- (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]; }
原文地址:https://www.cnblogs.com/neilHoIOS/p/4628435.html