0
这可能是一个有关iOS中的图层的初学者问题,但我找不出一个适当的方式来处理它...如何更新UIView的图层属性并为其保留子图层?
我以编程方式创建一个UIView并向它添加一个按钮。
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[mybutton setTitle:@"Test1" forState:UIControlStateNormal];
mybutton.frame = CGRectMake(0,0,50,50);
[subview mybutton];
比我做一些操作与子视图演示文稿更改它的图层属性。比如我更改视图边界半径,并添加阴影:
[subview.layer setCornerRadius:10.0f];
[subview.layer setShadowColor:[UIColor blackColor].CGColor];
[subview.layer setShadowOpacity:0.8];
[subview.layer setShadowRadius:3.0];
,我看到这则myButton层变化也并不仅是一个子视图的问题。 例如,按钮标题也有影子。 我做了一个示例截图,以更好地解释我的问题: http://img46.imageshack.us/img46/8923/havq.png
如何在iOS中处理它?是我添加按钮的另一种图层? 感谢您的建议和帮助!
谢谢你的帮助! – Eden1971