Reputation: 15639
Since iOS7, I have been searching for standard GUI design pattern.
In my previous two apps, I unchecked autolayout and used autosizing.
It usually looks like this
Main View looks like below in SIZE INSPECTOR.
Currently I am making two xibs, iPhone4 iPhone5 and use UIViewAutoresizingFlexibleTopMargin & UIViewAutoresizingFlexibleLeftMargin along with -64 in iOS6/7 Delta.
For Inner/Child Views, I usually Keep UIViewAutoresizingFlexibleTopMargin and UIViewAutoresizingFlexibleLeftMargin and -64 in iOS6/7 Delta to work fine in iOS6.
It give almost perfect result, but sometime I need to start View from start of xib (0,0) but sometime from (64,0) to show Views look like starting from upper most border of View while running.
It makes me confused a lot to understand what is standard way to design XIB, so that we can use single XIB for iPhone4 and iPhone5 and on both platforms.
Thanks
Upvotes: 5
Views: 2352
Reputation: 413
As described in apple developer official website, the below link exposes the guidelines of using Visual Format Language for auto layout which one is the best practices adopted among the iOS developers nowadays.
Upvotes: 0
Reputation: 52530
Best practice for using auto layout is to practice a lot until you get fluent using it :-(
You can then use several strategies.
The one that isn't going to work and that will make you pull your hair out is trying to combine interface builder and constraints in code. Don't do that.
The second that works after you figured out things is to do everything, design and layout using layout constraints, in interface builder. Note that layout constraints can be IBOutlets and that you can manipulate the constants of layout constraints in code quite easily.
The third that also works is to create your views in code, including the layout constraint. Use or write a library that makes creating constraints easier.
Upvotes: 0
Reputation: 2484
Writing Auto Layout code from scratch isn't easy.There is similar option available for AutoLayout stuff. We can set all constraints programatically with the help of PureLayout. https://github.com/PureLayout/PureLayout
Installation:
Add the pod PureLayout
to your Podfile.
pod 'PureLayout'
Run pod install
from Terminal, then open your app's .xcworkspace
file to launch Xcode.
Import the PureLayout.h
umbrella header.
With use_frameworks!
in your Podfile
Swift: import PureLayout
Objective-C: #import <PureLayout/PureLayout.h>
(or with Modules enabled: @import PureLayout;
)
Without use_frameworks!
in your Podfile
Swift: Add #import "PureLayout.h"
to your bridging header.
Objective-C: #import "PureLayout.h"
You are done!. Now make some beautiful design with PureLayout
Upvotes: 0
Reputation: 4455
Personally, I find that using Interface Builder with AutoLayout is not very user friendly and that it quickly became messy.
I prefer do all AutoLayout stuff programmatically. To avoid lot of boilerplate, I use the Masonry library which is quite amazing.
Upvotes: 4