I'm attempting to use UIModalPresentationFormSheet with a dark background but the corners of the开发者_Go百科 view always have a little white showing.
You can see a picture here.
I haven't seen this happen before. Any ideas on what is causing this?
First import "QuartzCore/QuartzCore.h" in which ViewController will show as UIModalPresentationFormSheet then override the viewWillAppear
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.view.superview.layer.cornerRadius = 10;
self.view.superview.layer.borderColor = [UIColor darkGrayColor].CGColor;
self.view.superview.layer.borderWidth = 1;
self.view.superview.clipsToBounds = YES;
}
If you want the shadow you shouldn't clip to the superview's bounds.
This solution will keep the shadow visible.
self.view.superview.layer.cornerRadius = 7.f;
for (CALayer *layer in self.view.superview.layer.sublayers)
if (layer != self.view.layer)
layer.cornerRadius = 8.f;
SpecPopover *ctrl = [[SpecPopover alloc] initWithNibName:@"SpecPopover" bundle:nil];
// Create a Navigation controller
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:ctrl];
[self.navigationController pushViewController:ctrl animated:YES];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
navController.view.backgroundColor = [UIColor clearColor];
// show the navigation controller modally
[self presentModalViewController:navController animated:YES];
navController.view.superview.frame = CGRectMake (200,200,400,400);
// Following removes the white round edges from the corner. <<<<<<<<-------------
navController.view.superview.layer.cornerRadius = 8;
navController.view.superview.layer.borderColor = [UIColor clearColor].CGColor;
navController.view.superview.layer.borderWidth = 2;
navController.view.superview.clipsToBounds = YES;
[navController release];
[ctrl release];
精彩评论