Category Archives for Auto Layout

Content Hugging and Compression Resistance Explained

This post takes a detailed look at Content Hugging Priority and Compression Resistance Priority. It is an interactive discussion with examples so if you can perform the steps in this post yourself, you’ll

Continue reading

UIStackView For Showing And Hiding User Interface Controls

Let’s take a look at a very useful feature of UIStackView: showing and hiding user interface controls. In an earlier tutorial, I demonstrated how to implement a custom edit button in each row for

Continue reading

UITableView Blur Background Including Rotation Support

Let’s build a beautiful UITableView that has a UIVisualEffectView with a UIBlurEffect. Let’s also go further and avoid a common problem of the blur being offset from the underlying image

Continue reading

When To Set Constraint Priority Less Than 1000 – A Case Study

Have you completed an entire app without ever deviating from the default constraint priority of 1000? Let’s take a look at an example of when you can leverage the ability to lower the constraint

Continue reading

setNeedsDisplay And drawRect Explained

In my previous post, I explained the difference between setNeedsLayout and layoutIfNeeded. This post covers another related and important method of UIView, which is setNeedsDisplay. 29 March 2017: Please

Continue reading

setNeedsLayout vs layoutIfNeeded Explained

Let’s take a look at the difference between setNeedsLayout and layoutIfNeeded. This post will explain the difference using a concrete example of animating constraint changes. Before discussing both

Continue reading

How To Access Storyboard and Xib Constraints in Code

A reader commented on a previous tutorial about not having realized that you can access a constraint (NSLayoutConstraint) in code just like you can any UIKit component such as a button or label. Let’s

Continue reading

UITextView Placeholder Text in Swift (IBDesignable in IB)

This post is a brief tutorial of a UITextView with placeholder text, written in Swift. It is implemented as a subclass of UIView using a Xib, and supports IBDesignable and IBInspectable. The 2 classes

Continue reading