背景颜色调整到圆角视图

时间:2011-10-10 14:43:54

标签: iphone

我有一种看法,就是我为自己做了并且完成了它的角落。当我尝试调整backgroundColor属性时,我最终会得到背景颜色作为正方形,不尊重我的圆角。

有解决方案吗?

提前致谢。

2 个答案:

答案 0 :(得分:0)

调用[[yourView layer] setMasksToBounds:YES];它应该剪掉圆角。

我很确定你甚至不需要setClipsToBounds。

有关图层主题的更多信息: http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/

答案 1 :(得分:0)

尝试使用此代码一次。

self.settingsView.frame=CGRectMake(18, 73, 284, 210);
[self.settingsView setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1]];
[self.settingsView setClipsToBounds:YES];
//Enable maskstobound so that corner radius would work.
[self.settingsView.layer setMasksToBounds:YES];
//Set the corner radius
[self.settingsView.layer setCornerRadius:10.0];
//Set the border color
[self.settingsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
//Set the image border`enter code here`
[self.settingsView.layer setBorderWidth:2.0];