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

Cem Kazım
1 min readNov 27, 2020

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
  • Subtitle
  • Button
  • One more button
  • TextField

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.

--

--