Modern Auto Layout - Programming Ebook

Latest

Download Programming Ebook

Friday, December 6, 2019

Modern Auto Layout




Book Details 
             TitleModern Auto Layout
         Author: Keith Harrison
    Language: English
        SubjectSwift / Computers & Technology / Programming / Apple Programming
No. of pages: 452
         Format: PDF


Modern Auto Layout
Building Adaptive Layouts For iOS


Introduction

You may have heard Auto Layout described as a constraint-based layout engine. What does that mean? Do you need to know math and write equations? Why is that any better than manually calculating the size and position of each view in your layout?
Have you been resisting using Auto Layout? Maybe you tried it and gave up in frustration? Or maybe you’re new to iOS development and wondering how to get started. Well, this book is for you.

Why Learn Auto Layout?

Apple first introduced us to Auto Layout in OS X 10.7 Lion. It took a while longer to come to iOS developers as part of iOS 6 unveiled at WWDC 2012. Auto Layout promises to make your layouts simpler to write, easier to understand, and less effort to maintain.

Using Auto Layout can feel a little abstract at first. Instead of manually setting the frame of each view you describe the relationships between your views with constraints and Auto Layout sets the frames for you. The advantage comes when your layout needs to respond and adapt to changes.
Dynamic sizing needs a dynamic layout. A modern iOS App needs to adapt to a broad set of user interface situations:
Layouts need to scale from the smallest device like the iPhone SE up to the largest 12.9" iPad Pro and work in slide over and split screen modes.
Text size can change significantly with localization and even more dramatically with dynamic text. Paragraphs of text that fit comfort-Modern Auto Layout 1. Introduction
ably at small text sizes can grow to where one word fills the screen at the largest of the accessibility sizes.
You need to be able to quickly adapt when Apple introduces new devices like the iPhone X with a top sensor housing and home screen indicator.

You don’t have to use Auto Layout, but many of the above challenges become manageable when you describe the relationships between your views with constraints. For example, layouts built with Auto Layout for the iPhone X in 2017 often only need rebuilding with the iOS 12 SDK to support the new screen sizes of the iPhone XR and iPhone XS Max in 2018.

Modern Auto Layout

What do I mean by “Modern Auto Layout”? A lot has changed over the years since Apple introduced Auto Layout in iOS 6. For me, Modern Auto Layout began with iOS 9:
  • In iOS 9, Apple added layout anchors and layout guides. They also added stack views and using Auto Layout got a whole lot less painful.
  • In iOS 10, adopting Dynamic type became less work with automatic font adjustments to content size changes.
  • In iOS 11, safe area layout guides and safe area relative margins replaced top and bottom layout guides. You can change the margins of the root view. Scroll views got layout guides, and stack views got custom spacing.
  • In iOS 12, Apple improved the performance of Auto Layout.
    Before We Get Started
    I assume you have a basic knowledge of iOS app development. You should be comfortable using Xcode to create an app and run it on the simulator or device.
    This book doesn’t teach you Swift or Objective-C programming or much about App architecture. I’ve used Swift for the code examples but don’t worry if you’re not an expert Swift programmer.
    If you’re new to Xcode and iOS development I recommended you first study an introductory tutorial such as Apple’s own “Start Developing iOS Apps (Swift)” guide:
Modern Auto Layout 1. Introduction https://developer.apple.com/library/content/referencelibrary/Getti
ngStarted/DevelopiOSAppsSwif t/
You may also want to read Appendix A: Tour Of Interface Builder. 


Advanced iOS Summer Bundle 2019 Ray Wenderlich


No comments:

Post a Comment