1

我正在开发 iPad 应用程序,有时我需要在 IBAction 上弹出视图。我用下面的代码也做了同样的事情。

SCSelection *vcSCSelection = [[SCSelection alloc]initWithNibName:@"SCSelection" bundle:Nil];
vcSCSelection.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:vcSCSelection animated:YES];

它工作正常,并向我展示了我的视图,它的大小是Form Sheet。我需要在此视图上应用一些背景自定义颜色,并在弹出视图的- (void)viewDidLoad方法中维护,如下所示。

self.view.backgroundColor = [UIColor colorWithRed:61/255.0 green:61/255.0 blue:61/255.0 alpha:1];

现在,我的问题是当弹出视图显示它被背景颜色覆盖时,除了它的角落如下。如您所见,有些角落空间不适用颜色效果。我只是用椭圆形突出它。 在此处输入图像描述 我该如何克服这个问题。

4

1 回答 1

0

我有一个类似的问题,这里有一篇关于我是如何做到的评论的快速文章。请注意,此代码位于触发模式视图呈现的视图控制器中。

    // Login Table View Controller
    UITableViewController *loginPanel = (UITableViewController*)  [mainStoryboard instantiateViewControllerWithIdentifier: @"LoginTVC"];

    // Setup Login panel presentation style
    loginPanel.modalPresentationStyle               = UIModalPresentationFormSheet;

    // Present Login Panel (called before view's bounds modifications so that it instantiates
    [self presentViewController:loginPanel animated:YES completion:nil];

    // ============================================
    // Make form sheet's view slightly smaller or
    // equal to the login panel's view so that corners
    // don't have white color bleed.
    // ============================================

    // Set the bounds & clipping (very important) of the
    // superview (which would be the formsheet's view
    // when using UIModalPresentationFormSheet)
    loginPanel.view.superview.bounds                = CGRectMake(0, 0, 400, 380);
    loginPanel.view.superview.layer.cornerRadius    = 8.0f; 
    loginPanel.view.superview.clipsToBounds         = YES;

    // Set the bounds of the view being presented modally as UIModalPresentationFormSheet 
    loginPanel.view.bounds                          = CGRectMake(0, 0, 400, 380);
于 2013-05-11T02:23:41.050 回答