Swift

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

This blog post will give you a brief introduction to a Test-Driven Development(TDD) in Swift and will demonstrate how you can create a very basic Unit test in Swift to test a User Model Struct that holds the details of the Account Registration form. Assume that you need to follow the Test-Driven development approach to…

Read More Swift Unit Test of User Registration Model

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

In this tutorial, you will learn how to underline text on UILabel in Swift programmatically. To make the text on UILabel underlined we will need to use the NSMutableAttributedString together with NSUnderlineStyleAttributeName. The Swift code snippet below demonstrates how to create a new UILabel programmatically and then use the NSMutableAttributedString to underline the text on the label. Create a…

Read More Underline Text on UILabel in Swift

If needed, it is possible to make UILabel clickable in Swift although it is recommended to use UIButton instead. To make UILabel clickable in Swift, you will need to create a UITapGestureRecognizer and then add it to a label. In this tutorial, you will learn how to create UILabel in Swift programmatically and how to…

Read More Clickable UILabel in Swift Programmatically

When writing code, we organize functionality into functions and group functions and different properties into classes. In Swift, additionally to creating classes we can also create structures or struct for short. Although very similar, Swift classes are different from swift structures. Comparing Structures and Classes According to Swift documentation, structures and classes in Swift have many…

Read More Swift Struct Tutorial with Code Examples

In this tutorial, you will learn how to create UILabel programmatically using a specific height, width, and position as well as using an auto layout. To write Swift code I will use Xcode Playground and if you are interested to learn how to create a new Xcode Playgrounds project, have a look at this tutorial…

Read More Create UILabel Programmatically in Swift

In this tutorial, you will learn how to send HTTP Post Request in Swift and how to read HTTP Response and Response Body. This tutorial will cover: Send HTTP Post Request, Convert Query String request parameters to JSON, Convert Swift structure to JSON, Set HTTP Request Headers, Read HTTP Response, Read HTTP Response Headers, Read HTTP…

Read More HTTP POST Request Example in Swift

In this short tutorial, you will learn how to add Biometric Authentication to your iOS app built with Swift. iOS devices starting from iPhone 5S until iPhone 8 Plus will use Touch ID for biometric authentication, while devices starting from iPhone X and above will use Face ID for biometric authentication. Update Info.plist File To be…

Read More Touch ID or Face ID Authentication in Swift

In this short tutorial, you will learn how to convert JSON string to a struct or a class in Swift. JSON String Let’s assume we have a web service endpoint which returns us a JSON string containing the following user details: {“firstName”:”Sergey”,”lastName”:”Kargopolov”,”email”:”[email protected]”,”userId”:”7fc0631b-7116-4d41-8d87-78f97b4dc543″} Swift Data Structure. Conforming to Codable or Encodable. We need to write Swift code…

Read More Convert JSON to Swift Class or Struct