在同时设置UIView
层的圆角和重写-drawRect:
方法时,是否可能?目前,-drawRect:
调用似乎会覆盖层的圆角并使其再次呈现为角形,即使-drawRect:
只包含对超类的-drawRect:
调用。
在同时设置UIView
层的圆角和重写-drawRect:
方法时,是否可能?目前,-drawRect:
调用似乎会覆盖层的圆角并使其再次呈现为角形,即使-drawRect:
只包含对超类的-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;
}
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if(self)
{
self.layer.cornerRadius = KCORNERRAD;
self.opaque = NO;
}
return self;
}
self.opaque = NO
没有起作用,但是masksToBounds = YES
起了作用。 - mahboudz