ios新建CALayer
1 // 如果一个控制是另外一个控件的子控件, 那么这个控件中的layer也是另外一个控件的子layer 2 NSLog(@"star - %@", self.view.layer.sublayers); 3 CALayer *layer = [CALayer layer]; 4 layer.backgroundColor = [UIColor redColor].CGColor; 5 layer.bounds = CGRectMake(0, 0, 100, 100); 6 layer.position = CGPointMake(200, 200); 7 layer.contents = (id)[UIImage imageNamed:@"me"].CGImage; 8 [self.view.layer addSublayer:layer];