Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Why do I have white, rounded corners on my modal view?

Tags:

ios

iphone

ipad

I have a modal view popping up in my iPad app and for some reason it has white, rounded corners.

It might be worth noting I built this model view in my storyboard, not programmatically. However, in my viewWillAppear method, I'm setting the corner radius like so...

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.view.layer.cornerRadius = 6.0f;
}

When I set the value above 6, the white corners become visible. How can I set the value higher without these white rounded corners showing?

Thanks so much in advance for your wisdom!

like image 740
BeachRunnerFred Avatar asked Oct 19 '12 00:10

BeachRunnerFred


2 Answers

Your question is ambiguous about what kind of presentation you're using for your view controller, so I'm going to assume you're using a form sheet. The solution is to set the superview's background color to [UIColor clearColor] to prevent the translucent background from appearing:

- (void) viewDidAppear:animated
{
    [super viewDidAppear:animated];

    self.view.layer.cornerRadius = 10;
    self.view.layer.masksToBounds = YES;
    self.view.superview.backgroundColor = [UIColor clearColor];
}

Before setting backgroundColor:

Before

After setting backgroundColor:

After

like image 150
NathanAldenSr Avatar answered Sep 17 '22 13:09

NathanAldenSr


Try

[self.view superview].layer.cornerRadius = 21.0f;
[self.view superview].layer.masksToBounds = YES;
like image 40
Luke Avatar answered Sep 20 '22 13:09

Luke