SlideShare a Scribd company logo
1 of 15
1
Auto Layout
Presenter: Waseem Ahmad, Mindfire Solutions
Date: 04/03/2015
Today
Presenter: Waseem Ahmad, Mindfire Solutions
What is Autolayout?
Why do we need Autolayout?
Autolayout via StoryBoard.
Intrinsic Content Size.
Content Hugging & Content Resistance Priority.
Auto Layout Demo.
What is Autolayout?
• Setting UIView frames using rules rather than numbers. i.e No use of auto resizing
mask.
• We need to put some rules on the views in their place no matter what bounds are
available. We call these rules “constraints”.
• There is a very powerful API (NSLayoutConstraint) for doing this using code, but We
almost set up these rules in Xcode graphically i.e storyboard or xib.
• Today, we will discuss these rules using storyboard.
Presenter: Waseem Ahmad, Mindfire Solutions
Why do we need Autolayout?
Because many things affect the size of the area available to put views
•Multiple iOS versions (6, 7, 8, 9?)
•Screen sizes, iPhone 4, 4S, 5, 5S, 6, 6 Plus & iPad Variations
•To support autorotation (Portrait vs Landscape)
•Dynamic Content
•Localization
Presenter: Waseem Ahmad, Mindfire Solutions
Autolayout via storyboard?
The fundamental building block in Auto Layout is the constraint (rules).
Constraints express rules for the layout of elements in your interface and apply
attributes “left, right, top, bottom, leading, trailing, width, height, centerX, centerY,
and baseline” etc.
Presenter: Waseem Ahmad, Mindfire Solutions
How to apply Rules?
•Adding Constraints with Control-Drag
•Adding Constraints with Align and Pin Menus
Presenter: Waseem Ahmad, Mindfire Solutions
Intrinsic Content Size
The size of the view based on the content it display.
•For example, UILabel has a preferred height based on the font, and a preferred
width based on the font and the text it displays.
•A UIProgressView only has a preferred height based on its artwork, but no preferred
width.
•A plain UIView has neither a preferred width nor a preferred height.
Presenter: Waseem Ahmad, Mindfire Solutions
Intrinsic Content Size
•We do not want to add explicit width and hight constraints to a view that has an
intrinsic content size.
•At run time, infer size based on content, grow and resize dynamically.
•It depends on two constants per direction (horizontally, vertically)
• Content Hugging
• Content Resistance
Presenter: Waseem Ahmad, Mindfire Solutions
Content Hugging & Content
Resistance Priority
Content Hugging Priority
• High Value, don’t want to grow.
Content Resistance Priority
• High value fight to shrink, maintaining it’s intrinsic content size.
Presenter: Waseem Ahmad, Mindfire Solutions
Content Hugging & Content
Resistance Priority
•Both horizontal and vertical priorities (between 0 to 1000).
•Value doesn’t matter, you need to decide the priority between 2 items.
Presenter: Waseem Ahmad, Mindfire Solutions
Demo
• Login Screen
Presenter: Waseem Ahmad, Mindfire Solutions
Key principles for Auto Layout
•Think and define relationship between views and superview.
•Constraints must be sufficient and not conflict.
• Less try to use less magic numbers.
•Don’t over-specify constraints. Just say as little as possible to communicate the
layout and no more.
•Avoid letting IB define constraints for you. Unless your view is very simple, IB will
probably get it wrong.
•Mastering Autolayout is depend on experience and practice.
Presenter: Waseem Ahmad, Mindfire Solutions
References
- Apple WWDC 2013
- Apple WWDC 2014
- Apple Inc. “Autolayout Guide”.
- Standford Autolayout Demo “http://www.stanford.edu"
Presenter: Waseem Ahmad, Mindfire Solutions
Presenter: Waseem Ahmad, Mindfire Solutions
Question and Answer
Thank you
Presenter: Waseem Ahmad, Mindfire Solutions

More Related Content

Viewers also liked (8)

Autolayout
AutolayoutAutolayout
Autolayout
 
View controllerp gforios
View controllerp gforiosView controllerp gforios
View controllerp gforios
 
Android picasso
Android picassoAndroid picasso
Android picasso
 
iOSプログラミングでAutoLayoutを数式のように記述する
iOSプログラミングでAutoLayoutを数式のように記述するiOSプログラミングでAutoLayoutを数式のように記述する
iOSプログラミングでAutoLayoutを数式のように記述する
 
Autolayout in iOS
Autolayout in iOSAutolayout in iOS
Autolayout in iOS
 
Autolayout primer
Autolayout primerAutolayout primer
Autolayout primer
 
Autolayout
AutolayoutAutolayout
Autolayout
 
Autolayout keynote
Autolayout keynoteAutolayout keynote
Autolayout keynote
 

Similar to Introduction to Auto-layout : iOS/Mac

Design4Drupal Boston 2013 - Bumps in the Road to Responsive
Design4Drupal Boston 2013 - Bumps in the Road to ResponsiveDesign4Drupal Boston 2013 - Bumps in the Road to Responsive
Design4Drupal Boston 2013 - Bumps in the Road to Responsive
Salem Ghoweri
 
Responsive Web design _2013
Responsive Web design _2013 Responsive Web design _2013
Responsive Web design _2013
Suresh B
 
responsive web design
responsive web designresponsive web design
responsive web design
Suresh B
 

Similar to Introduction to Auto-layout : iOS/Mac (20)

Design Like a Pro: Building Mobile-Responsive HMIs in Ignition Perspective
Design Like a Pro: Building Mobile-Responsive HMIs in Ignition PerspectiveDesign Like a Pro: Building Mobile-Responsive HMIs in Ignition Perspective
Design Like a Pro: Building Mobile-Responsive HMIs in Ignition Perspective
 
Design responsively
Design responsivelyDesign responsively
Design responsively
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
HTML and Responsive Design
HTML and Responsive Design HTML and Responsive Design
HTML and Responsive Design
 
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentationsUX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
UX Alive Conference speaker is Vitaly Friedman (Smashing Magazine) presentations
 
Secrets of responsive web design by Sameera Thilakasiri
Secrets of responsive web design by Sameera ThilakasiriSecrets of responsive web design by Sameera Thilakasiri
Secrets of responsive web design by Sameera Thilakasiri
 
How to Project-Manage and Implement a Responsive Website
How to Project-Manage and Implement a Responsive WebsiteHow to Project-Manage and Implement a Responsive Website
How to Project-Manage and Implement a Responsive Website
 
What are the Steps involved in Making WordPress.pptx
What are the Steps involved in Making WordPress.pptxWhat are the Steps involved in Making WordPress.pptx
What are the Steps involved in Making WordPress.pptx
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
Xamarin 9/10 San Diego Meetup
Xamarin 9/10 San Diego MeetupXamarin 9/10 San Diego Meetup
Xamarin 9/10 San Diego Meetup
 
Responsive Web design Zambig
Responsive Web design ZambigResponsive Web design Zambig
Responsive Web design Zambig
 
Responsive Web Design
Responsive Web Design Responsive Web Design
Responsive Web Design
 
Design4Drupal Boston 2013 - Bumps in the Road to Responsive
Design4Drupal Boston 2013 - Bumps in the Road to ResponsiveDesign4Drupal Boston 2013 - Bumps in the Road to Responsive
Design4Drupal Boston 2013 - Bumps in the Road to Responsive
 
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin..."Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
 
Responsive Web design _2013
Responsive Web design _2013 Responsive Web design _2013
Responsive Web design _2013
 
responsive web design 1_oct_2013
responsive web design  1_oct_2013 responsive web design  1_oct_2013
responsive web design 1_oct_2013
 
Rwd ppt
Rwd pptRwd ppt
Rwd ppt
 
responsive web design
responsive web designresponsive web design
responsive web design
 
Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web Design
 
WUD Rome 2014 - Delightful UX – Real-Life Responsive Web Design (EN) - Vitaly...
WUD Rome 2014 - Delightful UX – Real-Life Responsive Web Design (EN) - Vitaly...WUD Rome 2014 - Delightful UX – Real-Life Responsive Web Design (EN) - Vitaly...
WUD Rome 2014 - Delightful UX – Real-Life Responsive Web Design (EN) - Vitaly...
 

More from Mindfire Solutions

More from Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 
Angular In Depth
Angular In DepthAngular In Depth
Angular In Depth
 
Django Models
Django ModelsDjango Models
Django Models
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

Introduction to Auto-layout : iOS/Mac

  • 1. 1 Auto Layout Presenter: Waseem Ahmad, Mindfire Solutions Date: 04/03/2015
  • 2. Today Presenter: Waseem Ahmad, Mindfire Solutions What is Autolayout? Why do we need Autolayout? Autolayout via StoryBoard. Intrinsic Content Size. Content Hugging & Content Resistance Priority. Auto Layout Demo.
  • 3. What is Autolayout? • Setting UIView frames using rules rather than numbers. i.e No use of auto resizing mask. • We need to put some rules on the views in their place no matter what bounds are available. We call these rules “constraints”. • There is a very powerful API (NSLayoutConstraint) for doing this using code, but We almost set up these rules in Xcode graphically i.e storyboard or xib. • Today, we will discuss these rules using storyboard. Presenter: Waseem Ahmad, Mindfire Solutions
  • 4. Why do we need Autolayout? Because many things affect the size of the area available to put views •Multiple iOS versions (6, 7, 8, 9?) •Screen sizes, iPhone 4, 4S, 5, 5S, 6, 6 Plus & iPad Variations •To support autorotation (Portrait vs Landscape) •Dynamic Content •Localization Presenter: Waseem Ahmad, Mindfire Solutions
  • 5. Autolayout via storyboard? The fundamental building block in Auto Layout is the constraint (rules). Constraints express rules for the layout of elements in your interface and apply attributes “left, right, top, bottom, leading, trailing, width, height, centerX, centerY, and baseline” etc. Presenter: Waseem Ahmad, Mindfire Solutions
  • 6. How to apply Rules? •Adding Constraints with Control-Drag •Adding Constraints with Align and Pin Menus Presenter: Waseem Ahmad, Mindfire Solutions
  • 7. Intrinsic Content Size The size of the view based on the content it display. •For example, UILabel has a preferred height based on the font, and a preferred width based on the font and the text it displays. •A UIProgressView only has a preferred height based on its artwork, but no preferred width. •A plain UIView has neither a preferred width nor a preferred height. Presenter: Waseem Ahmad, Mindfire Solutions
  • 8. Intrinsic Content Size •We do not want to add explicit width and hight constraints to a view that has an intrinsic content size. •At run time, infer size based on content, grow and resize dynamically. •It depends on two constants per direction (horizontally, vertically) • Content Hugging • Content Resistance Presenter: Waseem Ahmad, Mindfire Solutions
  • 9. Content Hugging & Content Resistance Priority Content Hugging Priority • High Value, don’t want to grow. Content Resistance Priority • High value fight to shrink, maintaining it’s intrinsic content size. Presenter: Waseem Ahmad, Mindfire Solutions
  • 10. Content Hugging & Content Resistance Priority •Both horizontal and vertical priorities (between 0 to 1000). •Value doesn’t matter, you need to decide the priority between 2 items. Presenter: Waseem Ahmad, Mindfire Solutions
  • 11. Demo • Login Screen Presenter: Waseem Ahmad, Mindfire Solutions
  • 12. Key principles for Auto Layout •Think and define relationship between views and superview. •Constraints must be sufficient and not conflict. • Less try to use less magic numbers. •Don’t over-specify constraints. Just say as little as possible to communicate the layout and no more. •Avoid letting IB define constraints for you. Unless your view is very simple, IB will probably get it wrong. •Mastering Autolayout is depend on experience and practice. Presenter: Waseem Ahmad, Mindfire Solutions
  • 13. References - Apple WWDC 2013 - Apple WWDC 2014 - Apple Inc. “Autolayout Guide”. - Standford Autolayout Demo “http://www.stanford.edu" Presenter: Waseem Ahmad, Mindfire Solutions
  • 14. Presenter: Waseem Ahmad, Mindfire Solutions Question and Answer
  • 15. Thank you Presenter: Waseem Ahmad, Mindfire Solutions