文件名称:直接设置图层的属性-intel单cpu芯片组上电时序
文件大小:20.35MB
文件格式:PDF
更新时间:2024-07-30 20:55:49
iOS动画, core animation, 核心动画
清单7.4 直接设置图层的属性 @interface ViewController () @property (nonatomic, weak) IBOutlet UIView *layerView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //set the color of our layerView backing layer directly self.layerView.layer.backgroundColor = [UIColor blueColor].CGColor; } - (IBAction)changeColor { //begin a new transaction [CATransaction begin]; //set the animation duration to 1 second [CATransaction setAnimationDuration:1.0]; //randomize the layer background color CGFloat red = arc4random() / (CGFloat)INT_MAX; CGFloat green = arc4random() / (CGFloat)INT_MAX; CGFloat blue = arc4random() / (CGFloat)INT_MAX; self.layerView.layer.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0].CGColor; //commit the transaction [CATransaction commit]; } ios核心动画高级技巧 170图层行为