Swift Tool Belt, Part 1: Adding a Border, Corner Radius, and Shadow to a UIView with Interface Builder

During my iOS work, I’ve assembled a set of code that I bring with me on every iOS project. I’m not talking about large frameworks or CocoaPods here. These are smaller Swift extensions or control overrides that are applicable to many projects. I think of them as my tool belt.

How to Programmatically Remove a Cell From a Static UITableView

There are two different ways to add cells to a UITableView. The first is by using dynamic prototype cells in your table view. For a dynamic table view, you programmatically arrange the cells and sections of the table view by implementing the UITableViewDataSource protocol in code. Using this method, you can display a variable number of […]

A UIStackView Hack for Stacking Child Views Compactly

Before I developed for iOS, I did a lot of Microsoft WPF programming. One of the layouts available on that platform was a WrapPanel. Microsoft’s WrapPanel is similar to Apple’s UIStackView in that it arranges child elements into a single line that can be oriented horizontally or vertically. There are many differences, but the one I […]

UIStackView Tricks: Proportional Custom UIViews with ‘Fill Proportionally’

In iOS 9, Apple introduced a very handy new UI concept: the UIStackView. Stack views help us quickly compose sequential “stacks” of views without Auto Layout. UIStackView offers a number of distribution and spacing options in Interface Builder. If you’re unfamiliar with UIStackView, I recommend reading “Exploring UIStackView Distribution Types” first. In this post, I’ll […]