UIModalPresentationFormSheet白色角落

时间:2011-04-03 07:16:46

标签: cocoa-touch ios ipad

我正在尝试使用深色背景的UIModalPresentationFormSheet,但视图的角落总是有一点白色显示。

您可以看到图片here.

我之前没有见过这种情况。关于导致这种情况的任何想法?

3 个答案:

答案 0 :(得分:6)

首先导入“QuartzCore / QuartzCore.h”,其中ViewController将显示为UIModalPresentationFormSheet,然后覆盖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;
}

答案 1 :(得分:3)

如果你想要阴影,你不应剪辑到超视图的界限。

此解决方案将保持阴影可见。

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;

答案 2 :(得分:2)

    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];