How to set UIViewController “extend edges” properties

后端 未结 3 735
情歌与酒
情歌与酒 2020-12-05 00:16

I see the following selections in Storyboard for extending the edges of a UIViewController\'s view under navBars/tabBars:

相关标签:
3条回答
  • 2020-12-05 00:35

    If you don't want to extend to any edges, just add:

    let viewController = UIViewController()
    viewController.edgesForExtendedLayout = []
    
    0 讨论(0)
  • 2020-12-05 00:36

    In Objective-C:

    - (void) viewDidLoad {
       [super viewDidLoad];
       [self initVars];
    }
    
    - (void) initVars {
       self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight | UIRectEdgeBottom;
       self.extendedLayoutIncludesOpaqueBars = YES;
    }
    

    The properties that you want is:

    self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeBottom;
    
    0 讨论(0)
  • 2020-12-05 00:42

    There is a couple of new properties in iOS7 to control those settings.

    edgesForExtendedLayout tells what edges should be extended (left, right, top, bottom, all, none or any combination of those). Extending bottom edge equals "Under Bottom Bars" tick, extending top edge equals "Under Top Bars" tick.

    extendedLayoutIncludesOpaqueBars tells if edges should be automatically extended under the opaque bars. So if you combine those two settings you can mimic any combination of interface builder ticks in your code.

    0 讨论(0)
提交回复
热议问题