Using UIEdgeInsets to layout a UIButton

Photo by James Sutton on Unsplash

You can use insets to layout the content of system or custom buttons. With insets you can add or remove space to the button’s title (titleEdgeInsets), image (imageEdgeInsets) and both the title and image together (contentEdgeInsets).

To see how these three properties work, create a button (UIButton) via a xib-file or in code. Give it only a center vertically and horizontally in superview…




Articles about Swift that take less than 10 minutes to read.

Recommended from Medium

iOS Notes 47 : How to solve “xCode no such file or directory error” ?

Futures/Promises in Swift Combine

D V N C I — A Storyboardless & Clean & Multidirectional Architecture

So you want to do mock testing in XCTest?

Round buttons with shadow

Add Firebase to Your iOS App Quickly [Updated 2020]

Static and Class Modifiers in Swift, iOS

LeetCode #7 Reverse Integer — Swift solution

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeroen de Vrind

Jeroen de Vrind

iOS Engineer at ABN Amro bank. Author of How to develop accessible iOS apps.

More from Medium

SwiftUI and UIKit Compatibility Research at LinkAja!

Swift 5.6: Combining Logical Operators

Geocoding in Swift

How to resolve the swiping right action when trying to navigate to a previous screen in iOS.