Swift

UIStepper is a control in iOS that is used to increment or decrement a numeric value. In this tutorial, you will learn how to create a UIStepper programmatically, add it as a subview, position it in the center of the UIView, make the UIStepper value continuously increment when a user taps and holds the button,…

Read More Create UIStepper Programmatically in Swift

In this tutorial, you will learn how to customize UINavigationBar appearance programmatically within a UIViewController. You will use the new UINavigationBarAppearance introduced in iOS 15, but I will also provide a fallback for earlier versions. Set the Navigation Bar Background and Title Color For iOS 14 and Earlier Before iOS 15, you would have to…

Read More Customize Navigation Bar Programmatically in Swift

In this tutorial, you will learn how to make UIImage circular programmatically in Swift. Making a UIImage circular programmatically in Swift involves several steps. Step 1: Create a UIImageView with Your Image First, you need to create a UIImageView instance within your UIViewController. Then set the image you want to display  UIImageView by initializing it with a…

Read More Make UIImage Circular Programmatically

In this tutorial, you will learn how to create UISegmentedControl programmatically in Swift. A UISegmentedControl is a horizontal control that consists of multiple segments, each segment functioning as a discrete button. You can use UISegmentedControl to create custom user interface elements for your app, such as a switch or a filter. Creating a UISegmentedControl programmatically…

Read More Create UISegmentedControl in Swift Programmatically

In this tutorial, you will learn how to create and customize UISlider programmatically in Swift. Creating and customizing a UISlider programmatically in Swift involves several steps. Here’s how you can do it: Step 1: Create UISlider Programmatically First, you need to create a UISlider programmatically. You can do this by creating a new instance of the…

Read More Create UISlider Programmatically in Swift

In this tutorial, you will learn how to create and customize UISwitch programmatically in Swift. Creating and customizing a UISwitch programmatically in Swift involves several steps. Here’s how you can do it: Step 1: Create a basic UISwitch First, import the UIKit framework and create a new class that inherits from UIViewController. Inside the viewDidLoad() method, instantiate a new UISwitch object.…

Read More Create UISwitch in Swift Programmatically

In this tutorial, you will learn how to create a UITextView programmatically, position it at the center of the view, change its background color, and dismiss the keyboard when the user taps away. You will also create a UITapGestureRecognizer, add it to the main view, and add the UITextView as a subview. Finally, you will create…

Read More Dismiss UITextView Keyboard When User Taps Away

In this tutorial, you will learn how to create and customize UITextView programmatically in Swift. Creating and customizing a UITextView programmatically in Swift involves several steps. Here’s how you can do it: Step 1: Create UITextView Programmatically To create UITextView programmatically, you will need to first create an instance of UITextView. This can be done…

Read More Create and Customize UITextView Programmatically in Swift

Creating a UITextView programmatically in Swift involves several steps. This tutorial will guide you through creating a UITextView, positioning it at a specific location within a view, centering it, changing its text color, and altering its background color. Step 1: Create UITextView Programmatically To create UITextView programmatically, you first need to create an instance of…

Read More Create UITextView Programmatically in Swift

In this tutorial, you will learn how to check if a UITextField contains a value in Swift. I will cover the following topics: Understanding the isEmpty property. Using the isEmpty property to check if a UITextField is empty. Handling the case when the UITextField is empty. If you are new to UITextField, check out this tutorial: Create…

Read More Check If UITextField Contains Value

In this Swift tutorial, you will learn how to create a UIBarButtonItem with an image programmatically. It will be a short tutorial, but it will cover the following code snippets in Swift: Creating a UIBarButtonItem with an image. Adding the UIBarButtonItem to the navigation bar. Handling the tap event of the UIBarButtonItem. If you are new to UIBarButtonItem, please check…

Read More UIBarButtonItem with Image Example in Swift

In this Swift tutorial, you will learn how to create UIBarButtonItem programmatically without using the storyboard or the interface builder. I will cover topics such as: Create UIBarButtonItem programmatically. How to set the right sidebar button item rightBarButtonItem. How to set the left sidebar button item leftBarButtonItem. How to set target action on UIBarButtonItem to…

Read More Create UIBarButtonItem Programmatically