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.
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).
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'.
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.
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).
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 = []
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With