How To Customize Title And Subtitle of UIAlertController in iOS Project?

Do you want to customize title and subtitle of UIAlertController? First of all, let’s see what UIAlertController means.

What is UIAlertController?

An object that displays an alert message to the user.

…an alert can include:

  • Title

In this article, we will see how to customize title and subtitle components.

Step 1: Let’s create a new function and enter a name this method.

  • We created an alert and added a button to this alert.

Step 2: Add a new method for attributed string.

What is NSAttributedString?

A string with associated attributes (such as visual style, hyperlinks, or accessibility data) for portions of its text.

attributedString() -> This method customizes the text, fontSize and color arguments with NSAttributedString.

Let’s look at the result.

Thank you for reading.

💻 iOS Developer 🎸 Rock Musician

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