Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set UIViewController "extend edges" properties

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

enter image description here

But how do I set these properties globally for all of my ViewControllers in code? As opposed to manually checking/unchecking on every ViewController in Storyboard.

like image 505
hgwhittle Avatar asked Sep 18 '13 14:09

hgwhittle


2 Answers

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.

like image 74
dieworld Avatar answered Sep 19 '22 11:09

dieworld


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

let viewController = UIViewController() viewController.edgesForExtendedLayout = [] 
like image 25
Shaked Sayag Avatar answered Sep 23 '22 11:09

Shaked Sayag