1
我试图添加一个CALayer作为另一个CALayer的子图层。但是只有父层被显示。这里是我的代码:CALayer隐藏它的子图层
//display a green square:
CALayer *shipContainer = [CALayer layer];
shipContainer.bounds = CGRectMake(0,0,200,200);
shipContainer.position = CGPointMake(600,500);
shipContainer.borderColor = [UIColor greenColor].CGColor;
shipContainer.borderWidth = 3;
//display a red dot inside the square:
CALayer *ship1 = [CALayer layer];
ship1.bounds = CGRectMake(0,0,20,20);
ship1.position = CGPointMake(600,500);
ship1.cornerRadius = 10;
ship1.backgroundColor = [UIColor redColor].CGColor;
[shipContainer addSublayer:ship1];
我随后致电[self.view.layer addSublayer:shipContainer];
,但只显示绿色广场。有什么想法吗?
正确!谢谢你的帮助! – Eric 2012-03-13 18:52:52