Изменить цвет фона, цвет кнопок, цвет заголовка и подзаголовка в UIAlertController - Swift 5
let dialog =
UIAlertController(
title: "",
message: "",
preferredStyle: .alert)
// For title
let attributedStringForTitle =
NSAttributedString(
string: "Позвонить в полицию",
attributes: [NSAttributedString.Key.
font:
UIFont.
boldSystemFont(
ofSize: 16), NSAttributedString.Key.
foregroundColor: UIColor.
black])
dialog.
setValue(
attributedStringForTitle,
forKey: "attributedTitle")
// For message
let attributedStringForMessage =
NSAttributedString(
string: "Выберите оператора",
attributes: [NSAttributedString.Key.
font:
UIFont.
systemFont(
ofSize: 14), NSAttributedString.Key.
foregroundColor: UIColor.
white])
dialog.
setValue(
attributedStringForMessage,
forKey: "attributedMessage")
// For view
dialog.view.subviews.first?.subviews.first?.subviews.first?.backgroundColor = UIColor.red)
// For button title
dialog.view.tintColor = .white
present(dialog, animated: true, completion: nil)
Возврат к списку