The following setting:
I have a popupViewController that has a custom subclass of UIView as its kind made in loadView
- (void)loadView { CGRect startingPopupSize = CGRectMake(0.0f, 0.0f, 300.0f, 160.0f); _popupView = [[MoviePopupView alloc] initWithFrame:startingPopupSize]; self.view = _popupView; }
in this subclass of UIView I have the following code in it the init method
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code self.layer.masksToBounds = YES; self.layer.opaque = NO; self.clipsToBounds = YES; self.backgroundColor = [UIColor whiteColor]; self.layer.borderWidth = 1.0f; self.layer.cornerRadius = 10.0f; } return self; }
the problem is that cornerRadius does not work for this view, but the border is drawn, see here:

if I don't replace this view with uiview by default for uiviewcontroller and instead add it as a subview, cornerRadius works just fine (I want to replace it for several reasons).
any ideas why this is not working?
Edit:
If I just move the properties of the masksToBounds = YES layers from the initWithFrame method to the drawRect method, it works. move it to your controllers view viewDidLoad no.
- (void)drawRect:(CGRect)rect {
any ideas why this works? I think this is not a suitable place to set this property here.
source share