SlideShare a Scribd company logo
Introduction to Auto Layout
July 17th, 2014
So why are we talking about Auto
Layout ?
?
New Devices
iWatch
y = m*x + b, where:
● y and x are attributes of views.
● m and b are floating point values.
Auto Layout is ….
Constraints
Constraints
UIActivityIndicatorView *indecator = [UIActivityIndicatorView new];
indecator.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:indecator];
[self addConstraint:[NSLayoutConstraint constraintWithItem:indecator
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterX
multiplier:1.
constant:0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem:indecator
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterY
multiplier:1.
constant:0]];
Visual format language
Standard Space
[button]-[textField]
Width Constraint
[button(>=50)]
Connection to Superview
|-50-[purpleBox]-50-|
Vertical Layout
V:[topField]-10-[bottomField]
Flush Views
[maroonView][blueView]
Priority
[button(100@20)]
Equal Widths
[button1(==button2)]
Multiple Predicates
[flexibleButton(>=70,<=100)]
Complete Line of Layout
|-[find]-[findNext]-
[findField(>=20)]-|
Visual format language
UIImageView *imageView = [UIImageView new];
imageView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:imageView];
NSDictionary *views = NSDictionaryOfVariableBindings(imageView);
[self addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|[imageView]|"
options:0
metrics:nil
views:views]];
[self addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[imageView]|"
options:0
metrics:nil
views:views]];
Pin menu
Why Auto Layout?
● Describe how views should be laid out in a relational
manner to their superview & sibling views
● Dynamically respond to application changes
● User provides constraints; system calculates the frames
● More power and control over springs and struts
Why Auto Layout?
● Multiple iOS versions (6, 7, 8...)
● Rotation
● Dynamic Content
● Screen sizes
Size classes
- Regular
- Compact
Size classes
Size classes
3. Size classes
Introduction to auto layout
Demo:
Debugging without running
IBDesignables
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface TestInspectorView : UIView
@end
Debugging without running
IBInspectable
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface TestInspectorView : UIView
@property (nonatomic) IBInspectable UIImage *photo;
@property (nonatomic) IBInspectable NSString *title;
@end
IBInspectable
Runtime attributes:
● boolean,
● number,
● string,
● localized string,
● rectangle,
● point,
● size,
● color,
● range,
● nil
Debugging Views
New live views functionality the ability
to debug views right in Interface
Builder.
Resizable iPhone and iPad simulators
Demo:
http://nsscreencast.com/episodes/138-ibdesignable
https://developer.apple.com/library/ios/recipes/xcode_help-
IB_objects_media/chapters/CreatingaLiveViewofaCustomObject.html#//apple_ref/doc/uid/TP40014224-CH41-SW1
https://developer.apple.com/library/ios/recipes/xcode_help-
IB_objects_media/chapters/DebuggingCustomViews.html#//apple_ref/doc/uid/TP40014224-CH42-SW1
https://www.youtube.com/watch?v=ugqFWPsY_A0
http://floriankugler.com/blog/2013/4/21/auto-layout-performance-on-ios
No Auto Layout
https://www.youtube.com/watch?v=I9VNHMbVZX4

More Related Content

PPT
Autolayout in iOS
PDF
Auto Layout on Xcode 5
PDF
Auto Layout
PDF
Auto layout in i os 7
PDF
Auto-Layout in iOS 7
PDF
Object Calisthenics in Objective-C
PPTX
Auto layout 介紹
PDF
Understanding Auto Layout
Autolayout in iOS
Auto Layout on Xcode 5
Auto Layout
Auto layout in i os 7
Auto-Layout in iOS 7
Object Calisthenics in Objective-C
Auto layout 介紹
Understanding Auto Layout

Viewers also liked (16)

PDF
X-Debug in Php Storm
PDF
Autolayout
PDF
Introduction to xcode
PPT
Introduction to data structures and Algorithm
PPTX
VIdeo Compression using sum of Absolute Difference
PDF
Code Review for iOS
PDF
Introduction of Xcode
PPTX
PPT
Swine flu
PPT
Network security
PPT
Token bus standard
PPT
Linux booting procedure
PDF
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
PPT
Serial Peripheral Interface(SPI)
PPTX
Mems technology
PDF
Ekonomiks lm yunit 4 (2)
X-Debug in Php Storm
Autolayout
Introduction to xcode
Introduction to data structures and Algorithm
VIdeo Compression using sum of Absolute Difference
Code Review for iOS
Introduction of Xcode
Swine flu
Network security
Token bus standard
Linux booting procedure
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Serial Peripheral Interface(SPI)
Mems technology
Ekonomiks lm yunit 4 (2)
Ad

Similar to Introduction to auto layout (20)

KEY
Opening iOS App 開發者交流會
PDF
Autolayout
PDF
IOS APPs Revision
PDF
I os 11
PDF
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
PDF
10 tips for a reusable architecture
PDF
I os 04
PDF
Leaving Interface Builder Behind
KEY
CocoaHeads Toulouse - Guillaume Cerquant - UIView
PPT
iOS Training Session-3
PPTX
iOS Beginners Lesson 4
PPTX
Riacon swiz
PDF
iPhoneOS3.1でのカメラAPIについて
PDF
Implementing Data Visualization Apps on iOS Devices
PDF
iOS Layout Overview
PPTX
Introduction to Google Guice
PPTX
New to native? Getting Started With iOS Development
PDF
Explaination of angular
PDF
Our Choice:电子书的新交互方式探讨
Opening iOS App 開發者交流會
Autolayout
IOS APPs Revision
I os 11
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
10 tips for a reusable architecture
I os 04
Leaving Interface Builder Behind
CocoaHeads Toulouse - Guillaume Cerquant - UIView
iOS Training Session-3
iOS Beginners Lesson 4
Riacon swiz
iPhoneOS3.1でのカメラAPIについて
Implementing Data Visualization Apps on iOS Devices
iOS Layout Overview
Introduction to Google Guice
New to native? Getting Started With iOS Development
Explaination of angular
Our Choice:电子书的新交互方式探讨
Ad

More from Ciklum Ukraine (20)

PDF
"How keep normal blood pressure using TDD" By Roman Loparev
PDF
"Through the three circles of the it hell" by Roman Liashenko
PDF
Alex Pazhyn: Google_Material_Design
PPTX
Introduction to amazon web services for developers
PPTX
Your 1st Apple watch Application
PDF
Test Driven Development
PPTX
Back to the future: ux trends 2015
PPTX
Developing high load systems using C++
PPTX
Collection view layout
PDF
Groovy on Android
PDF
Unit Testing: Special Cases
PPTX
Material design
PPTX
Kanban development
PPTX
Mobile sketching
PDF
More UX in our life
PDF
Model-View-Controller: Tips&Tricks
PDF
Unit Tesing in iOS
PDF
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
PDF
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
PDF
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"How keep normal blood pressure using TDD" By Roman Loparev
"Through the three circles of the it hell" by Roman Liashenko
Alex Pazhyn: Google_Material_Design
Introduction to amazon web services for developers
Your 1st Apple watch Application
Test Driven Development
Back to the future: ux trends 2015
Developing high load systems using C++
Collection view layout
Groovy on Android
Unit Testing: Special Cases
Material design
Kanban development
Mobile sketching
More UX in our life
Model-View-Controller: Tips&Tricks
Unit Tesing in iOS
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Teaching material agriculture food technology

Introduction to auto layout