5+1 Swift extensions to make your life easier

Balázs Vincze
3 min readJan 25, 2020

Thanks for stopping by, today I’ll show you five small Swift extensions I use in almost every iOS project.

🏁 Here we go:

1. Padding a UIButton

I often find myself having to add some padding to a UIButton. Instead of tweaking around with the titleEdgesInsets and contentEdgeInsets, I created this simple CGSize extension, which I then use in UIButton subclasses:

2. Highlighting parts of a String

It’s common to implement some sort of partial string highlighting when adding autocomplete to an app. To save myself some time, I use the following extension. The example demonstrates usage with a UILabel.

3. Subscripting Array using an IndexPath

--

--