是否可以在 UIView
的层上设置圆角并同时覆盖 -drawRect:
?目前,-drawRect:
调用似乎覆盖了层的圆角并使它们再次出现棱角,即使 -drawRect:
仅包含对 super 的 的调用-drawRect:
.
最佳答案
self.opaque = NO
对我不起作用。设置 self.layer.masksToBounds = YES
确实有效,但是(在 iOS 4.3 上测试):
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if( self )
{
self.layer.cornerRadius = 6.0f;
self.layer.masksToBounds = YES;
}
return self;
}
关于objective-c - UIView图层圆角和-drawRect :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7078911/