I am trying to override the drawRect:
method of UIView in my custom view. However, my view has a border radius defined as:
sub = [[[NSBundle mainBundle] loadNibNamed:@"ProfileView" owner:self options:nil] objectAtIndex:0];
[self addSubview:sub];
[sub setUserInteractionEnabled:YES];
[self setUserInteractionEnabled:YES];
CALayer *layer = sub.layer;
layer.masksToBounds = YES;
layer.borderWidth = 5.0;
layer.borderColor = [UIColor whiteColor].CGColor;
layer.cornerRadius = 30.0;
This works perfectly and places a nice border with a border radius around my view (don't mind the diagonal/straight white lines at the back, they have nothing to do with this view):
However, when I try to override the drawRect:
method in my view, I can see a black background not masking to bounds. I don't do anything (currently), here is my code:
-(void)drawRect:(CGRect)rect{
[super drawRect:rect];
}
And here is the result:
I've changed nothing but the draw method. How can I override the draw method while keeping my view obey the corner radius mask? Is this a bug in iOS or am I missing something?