UIButton

The code snippet in this blog post demonstrates how to create a UIButton with a background image. To break it down in details, the following Swift code example will cover how to: Create UIButton and position UIButton within a view, Add UIButton as Subview, Add target action to UIButton to call a local function when the button…

Read More UIButton with Background Image in Swift

In this Swift code example, you will learn how to disable UIButton. The quickest way to disable the button in Swift is to simply set the button’s isEnabled property to false. For example button.isEnabled = false.  Below is a complete code example in Swift that demonstrates how to: Create new UIButton, Position button within a view,…

Read More Disable UIButton Example in Swift

In this blog post, you will learn how to create a UIBarButtonItem with Image in Swift. It is going to be a very short and simple Swift code example, that demonstrates how to: Create UIBarButtonItem programmatically, Create UIImage programmatically, Add image to UIBarButtonItem, Add target action to UIBarButtonItem to call a local function. import UIKit class…

Read More UIBarButtonItem with Image Example in Swift

In this Swift code example, you will learn how to: Create UIBarButtonItem programmatically, How to set right side bar button item(rightBarButtonItem), How to set left side bar button item(leftBarButtonItem), How to set target action on UIBarButtonItem to call a custom function when the button is tapped. Below is a very simple code example in Swift…

Read More Create UIBarButtonItem Programmatically

In this XCTest tutorial, you will learn how to write a unit test that will test if UIButton is connected to @IBOutlet and has @IBAction assigned. For this tutorial, I will create a Single View application project. I will use the default View Controller that XCode creates for all new projects and I will position…

Read More XCTest. Test if UIButton is Connected And Has Action

In this short tutorial, you will learn how to set a different font on UIButton in Swift programmatically. There are lots of different customization you can with UIButton. For example, you might be also interested to learn how to create UIButton and change its style, background color, tint color and make it call a function…

Read More Set UIButton Font Programmatically in Swift

In this tutorial, you will learn how to create UIButton programmatically. You will also learn how to do the basic customization of UIButton like setting button tint color, background color and making your button call a function when tapped. Create UIButton A new UIButton can be created of different types: ButtonType.custom, ButtonType.system, ButtonType.detailDisclosure, ButtonType.infoLight, ButtonType.infoDark,…

Read More Create UIButton in Swift Programmatically