My Swift Tool Belt, Part 5: Adding a Gradient UIButton

The fifth item in my Swift Tool Belt is a class derived from UIButton that will draw your button with a gradient background. It will also expose the colors of your gradient in the attributes inspector of Xcode and render the gradient button directly in your storyboard. Read more on My Swift Tool Belt, Part 5: Adding a Gradient UIButton…

My Swift Tool Belt (Part 4): Extending UITableViewController

The fourth item in my Swift Tool Belt is an extension for UITableViewController. A UITableViewController is a view controller with a table view that takes up the entire screen. My extension provides a couple of methods to resize the header and footer of a table view. Read more on My Swift Tool Belt (Part 4): Extending UITableViewController…

My Swift Tool Belt (Part 3): Extending UILabel

The third item in my Swift Tool Belt is a couple of extensions on UILabel. These extensions will allow easy access to modify the edge insets on a label (the extra padding all around the text). There’s also an extension to add a rotation transform to a label. All of these extensions will be IBDesignable and IBInspectable for easy modification from Xcode’s Interface Builder. Read more on My Swift Tool Belt (Part 3): Extending UILabel…

My Swift Tool Belt, Part 2: Extending Date

The second item in my Swift Tool Belt is an extension on the Date class. The interface to the Date class in iOS is very powerful, but in my opinion, it is not very readable. Simple operations to add/remove time to a date can be several lines long. Many of my extensions help with the readability of the class. Read more on My Swift Tool Belt, Part 2: Extending Date…

My 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. Read more on My Swift Tool Belt, Part 1: Adding a Border, Corner Radius, and Shadow to a UIView with Interface Builder…

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 cells and sections at runtime. Read more on How to Programmatically Remove a Cell From a Static UITableView…

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 want to focus on is that a WrapPanel will space the content as close together as possible, and the size of the content is determined by its intrinsic content size. Read more on A UIStackView Hack for Stacking Child Views Compactly…

How to Remove Extra Separator Lines in a UITableView

When your UITableView does not have enough data to fill out the length of the screen, it will show empty cells with separators to fill out the screen. I have run into several situations where the extra separator lines are not wanted. If you have run into this yourself, then here is an easy trick to get rid of them that does not require any code. Read more on How to Remove Extra Separator Lines in a UITableView…

How to Use UISearchController to Add Search Your UITableViews

This is a simple tutorial on how to use the new UISearchController to add search capability to your UITableViews. The UISearchController was introduced a couple years ago in iOS 8 to replace the now deprecated UISearchDisplayController. In the new search controller, it is easier to add search to your table views. As of Xcode 8.1, the UISearchController has not been added to Interface Builder, so you have to add it programmatically. Even still, it is pretty easy to work with. Read more on How to Use UISearchController to Add Search Your UITableViews…

Auto Layout Demystified

I was at a local user group recently where the topic of the meeting was one of the hot new cross-platform mobile development options out there (doesn’t really matter which one). There was the usual UIkit bashing, which was expected since the topic was to propose an alternative programming model.

I’m not here to defend UIkit, because I agree that it can use some improvement. However, the speaker did say one thing about Auto Layout that I have heard before and that rubbed me the wrong way.
Read more on Auto Layout Demystified…