具有方形(0半径)角的UIModalPresentationFormSheet?

tod*_*ley 6 uimodalpresentationformsh ios4

默认情况下,iPad模态表单会出现圆角.在Apple的几个应用程序中,例如iTunes,表单有完美的方角.是否有一种相对简单的方法来删除不会让我从App Store中拒绝的角落半径?

小智 3

将其放入您所显示的视图中:

//You will have to link to the QuartzCore library
#import <QuartzCore/QuartzCore.h>

- (void)viewDidLoad
{
    [super viewDidLoad]; 
    //set border radius on initial load
    self.view.layer.cornerRadius = 0;
}

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
     //for some reason the cornerRadius resets itself on orientation change
    self.view.layer.cornerRadius = 0;
 }
Run Code Online (Sandbox Code Playgroud)

  • 在 viewWillAppear(而不是 viewDidLoad)处设置此值可确保您永远不会看到默认的斜角。否则,这就像一个魅力。谢谢。 (3认同)
  • 从 2016 年来到这里:这段代码对我不起作用,但 self.view.superview.layer.cornerRadius = 0; 做过。如果上面的代码不适合您,请尝试一下。 (2认同)