iOS7 autolayout for Automatic positioning and resizing UI elements

iOS7 autolayout for Automatic positioning and resizing UI elements

Autolayout is popular option in XCode to resizing the UI elements, Autolayout is the feature in iOS6 and above versions. Autolayout has become critical with the release of iOS7, as it supports many of its features like font size, text field controls, rotation etc and reduces the amount of work. To use autolayout go through the below path in XCode.

choose view>Utilities>Show file inspector and then select Use Autolayout option.

Autolayout is improved in XCode5, which enables to create much complicated views which was difficult to create with XCode4. Autolayout describes the relationship between the views, it uses NSLayoutConstraint objects. But NSLayoutConstraint describes only one relationship between views and there is need to resolve the X and Y positions. Autolayout has a popup feature to select constraint or multiple constraints and its values can be added by selecting, adding relation types like equal, greater than or constants.

XCode5 also describes more details on constraints, for example a particular added constraint can be satisfied or not. If some constraints does not fully satisfied then XCode5 issues a new panel with all the missing constraints and allows to add more constraints, delete constraints or update the existing constraints to satisfy the condition.

Autolayout considers priorities to the views to resolve the conflict, if priorities is not given to the views then iOS7 itself prioritize the views to avoid conflict.

If two constraints having the same priorities then iOS discards some of the conflicts. XCode5 also provide option to add the missing constraints, this option quickly adds the constraints and update the constraints in the interface and matches with the final values of the constraints.

iOS7 handles both legacy layout and iOS7 specific layouts by automatically adjusting inset of the view. iOS7 automatically adjusts the scroll views which includes status bar, navigation bar and the tab bar. It uses UIViewController and automaticallyAdjustsScrollViewInsets properties for the scroll view controls.

XCode5 has a new preview feature, the new preview feature is available on the Assistant editors location bar and select the file preview option here to view the file preview. There are various options available to see the file preview under iOS6, iOS7 and different screen sizes ratina 3.5’’ or ratina 4.0’’ screens.

 

The following two tabs change content below.