Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Where is the top layout guide in Xib file Interface Builder?

I'm currently developing iOS apps with swift. I want to develop my apps without storyboard just with the xib files and Grouping my Views and Controllers with seperate groups. But i realized a missing thing in xib file. I can not see top layout guide and bottom layout guide in xib file. I want to arrange my UIControls according to the layout guides. But there is no one? Is there another way to set constraints with top layout guide with interface builder without using Storyboards?

Thanks in advance.

like image 315
Alican Yilmaz Avatar asked Aug 06 '16 18:08

Alican Yilmaz


People also ask

What is top layout guide?

The topLayoutGuide property comes into play when a view controller is frontmost onscreen. It indicates the highest vertical extent for content that you don't want to appear behind a translucent or transparent UIKit bar (such as a status or navigation bar).

How do you add top and bottom layout in storyboard?

Select your view. Select 'Add New Constraints' option in the InterfaceBuilder. From the dropdown menu of top or bottom constraint, select the 'Top Layout Guide' or 'Bottom Layout Guide'.

How do I remove content layout guide?

Simply uncheck the Content Layout Guides. This option is found under the Size Inspector tab in storyboard. NOTE: This option is found under the Size Inspector tab in storyboard.

What's the difference between storyboard and XIB?

XIB and Storyboard are used for creating interfaces for users. One important point is,xibs are used for creating a single view(it has single file owner at the top of the xib file), but in-case for viewcontroller, multiple screens can be added and its flow can also be monitored(it has separate file owners).


2 Answers

If you do not want the entire view of the ViewController to extend underneath UINavigationBar when one is present. Turn off the edgesForExtendedLayout property of the UIViewController.

self.edgesForExtendedLayout = []
like image 73
Chi-Hwa Michael Ting Avatar answered Sep 20 '22 13:09

Chi-Hwa Michael Ting


This worked for me:

yourCustomView.topAnchor.constraint(equalTo: self.topLayoutGuide.bottomAnchor).isActive = true

from here: Is there any way to add constraint between a view and the top layout guide in a xib file?

like image 29
Jay Avatar answered Sep 21 '22 13:09

Jay