iOS Auto Layout Demystified

Book description

Auto Layout re-imagines the way developers create user interfaces. It provides a flexible and powerful system that describes how views and their content relate to each other and to the windows and superviews they occupy. In contrast to older design approaches, this technology offers incredible control over layout with a wider range of customization than frames, springs, and struts can express.

In this guide, Erica Sadun, bestselling author of The Core iOS 6 Developer's Cookbook and The Advanced iOS 6 Developer's Cookbook, helps readers learn how to use Auto Layout effectively, even masterfully, by providing an abundance of examples alongside plenty of explanations and tips. Instead of struggling with class documentation, you learn in simple steps how the system works and why it’s far more powerful than you first imagined. You read about common design scenarios and discover best practices that make Auto Layout a pleasure rather than a chore to use. Sadun includes examples of non-obvious ways to use Auto Layout to build interactive elements, animations, and other features beyond what you might normally lay out in Interface Builder to help expand the reader’s design possibilities. With this book you will learn

  • The basic concepts that form the foundation of Auto Layout

  • How to create clear and satisfiable rules of your layout, called constraints

  • How to work effectively with the Interface Builder Layout

  • What visual constraints look like, how to work with them, and how they are used in your projects

  • How to debug constraints

  • How to design interfaces when working with Auto Layout

  • Effective solutions to the most common real-world problems and challenges

  • Approximately 238 pages.

    For related content by author Erica Sadun, see The Core iOS 6 Developer’s Cookbook, and The Advanced iOS 6 Developer’s Cookbook.

    Table of contents

    1. Title Page
    2. Copyright Page
    3. Dedication Page
    4. Contents
    5. Acknowledgments
    6. About the Author
    7. Preface
      1. How This Book Is Organized
      2. About the Sample Code
      3. Contacting the Author
    8. Take Our Survey
    9. Editor’s Note: We Want to Hear from You!
    10. 1. Introducing Auto Layout
      1. Saying “No” to Auto Layout
      2. Saying “Yes” to Auto Layout
      3. Constraints
      4. Constraint Attributes
      5. Missing Views
      6. Ambiguous Layout
      7. Intrinsic Content Size
      8. Compression Resistance and Content Hugging
      9. Auto Layout and Frames
      10. Summary
    11. 2. Constraints
      1. Constraint Types
      2. Priorities
      3. Content Size Constraints
      4. Layout Constraints
      5. The Layout Constraint Class
      6. Creating Layout Constraints
      7. Using NSLayoutConstraint
      8. View Items
      9. Constraints, Hierarchies, and Bounds Systems
      10. Installing Constraints
      11. Removing Constraints
      12. Comparing Constraints
      13. Laws of Layout Constraints
      14. Summary
    12. 3. Interface Builder Layout
      1. Constraints in Interface Builder
      2. Constraint Listings
      3. Selecting Constraints
      4. Inspecting Constraints
      5. View Size Inspector
      6. Adding User Constraints
      7. Building New Constraints
      8. The Missing Views Problem
      9. Balancing Requests
      10. Constraints and Outlets
      11. Hybrid Layout
      12. Constraints/Resizing Pop-Up Menu
      13. Summary
    13. 4. Visual Formats
      1. Introducing Visual Format Constraints
      2. Options
      3. Variable Bindings
      4. Metrics
      5. Format String Structure
      6. Orientation
      7. View Names
      8. Connections
      9. View Sizes
      10. Format String Components
      11. Getting It Wrong
      12. NSLog and Visual Formats
      13. Constraining to a Superview
      14. View Stretching
      15. Constraining Size
      16. Building Rows or Columns
      17. Matching Sizes
      18. Why You Cannot Distribute Views
      19. Summary
    14. 5. Debugging Constraints
      1. Reading Console Logs
      2. Examining Constraint Logs
      3. A Note about Layout Math
      4. Constraint Equation Strings
      5. Adding Names
      6. Describing Views
      7. Example: Unexpected Padding
      8. Example: The Hugged Image
      9. Example: View Centering
      10. Descent Reports
      11. Example: Ambiguity
      12. Example: Expanding on Console Dumps
      13. Visualizing Constraints
      14. Launch Arguments
      15. Internationalization
      16. Profiling Cocoa Layout
      17. Auto Layout Rules of Debugging
      18. Summary
    15. 6. Building with Auto Layout
      1. Basic Principles of Auto Layout
      2. Layout Libraries
      3. Planning Interfaces
      4. Building for Modularity
      5. Updating Constraints
      6. Handling Orientation-Specific Text Layout
      7. Designing for Edge Conditions
      8. Building a View Drawer
      9. Window Boundaries
      10. Summary
    16. 7. Layout Solutions
      1. Table Cells
      2. Preserving Image Aspect
      3. Accordion Sizing
      4. Auto Layout
      5. Centering View Groups
      6. Custom Multipliers and Random Positions
      7. Building Grids
      8. Constraint Animation on Steroids
      9. Summary
    17. Index

    Product information

    • Title: iOS Auto Layout Demystified
    • Author(s):
    • Release date: April 2013
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780133440669