Swift

The below Swift code example demonstrates how to create a UIStepper programmatically. If we break it down into smaller parts the code example below also demonstrates: How to add UIStepper as a Subview, Add custom function which gets triggered when UIStepper value is changed, Position UIStepper in the center of UIView, Make UIStepper value continuously increment…

Read More Create UIStepper Programmatically

In this short blog post, you will learn how to create a UIView in Swift programmatically. The code example below will cover the following: How to create UIView in Swift programmatically, How to add UIView as a Subview, Change UIView background color Add a border around UIView, Change UIView border color, Make UIView corners rounded.…

Read More Create UIView in Swift Programmatically

This short example demonstrates how to create a UISwitch in Swift programmatically. The Swift code snippet below will coder the following: Create UISwitch in Swift programmatically, How to position UISwitch on a view, How to set UISwitch state to On and Off, How to call your custom function when UISwitch state changes. import UIKit class…

Read More Create UISwitch in Swift Programmatically

In this short Swift code example, I am going to share with you how to load the content of a property file into NSDictionary. And in this particular example, I will load the content of the Info.plist file which is available in our projects. But you can use this approach to load up the content…

Read More Info.plist. Read Content of a Property File in Swift

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

This code example demonstrates how to write and read from NSUserDefaults in Swift. The code example below will cover how to: Create a global instance of NSUserDefaults Write and read the following data types from NSUserDefaults: Integer Boolean Double Objects like String, Date and Array of elements Using NSUserDefaults in Swift. Code Example. // Create a…

Read More NSUserDefaults example 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

The two Swift code snippets below are examples of how to compare if two Strings are equal. Check if Two Strings are Equal Using elementsEqual() Let’s assume the two Strings are constants and we need to compare them: let password = “HelloWorld” let repeatPassword = “HelloWorld” if ((password.elementsEqual(repeatPassword)) == true) { print(“Passwords are equal”) } else {…

Read More Compare Two Strings 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

Free Video Lessons

Enter your email and stay on top of things,

Subscribe!