Готовый пример работа с alertController (alertController example) - Swift 5
// Текст для Message
let message = "Swift"
let alertController =
UIAlertController(
title: "ИНФОРМАЦИЯ",
message: message,
preferredStyle: .alert)
// Настройка заголовка (Title)
alertController.
setValue(
NSAttributedString(
string: alertController.
title!,
attributes: [NSAttributedString.Key.font :
UIFont.
systemFont(
ofSize: 17,
weight: UIFont.Weight.bold),
NSAttributedString.Key.
foregroundColor : UIColor.orange]),
forKey: "attributedTitle")
// Настройка собщения (Message)
alertController.
setValue(
NSAttributedString(
string: message,
attributes: [
NSAttributedString.
Key.
font :
UIFont.
systemFont(
ofSize: 15,
weight:
UIFont.Weight.regular),
NSAttributedString.
Key.
foregroundColor : UIColor.white]),
forKey: "attributedMessage")
// Цвет текста у кнопок
alertController.
view.
tintColor = .white
// Цвет фона
alertController.
view.
subviews.
first?.
subviews.
first?.
subviews.
first?.
backgroundColor = .red
let actionCancel =
UIAlertAction(
title: "Закрыть",
style: .cancel) { (action)
in
}
alertController.
addAction(actionCancel)
present(
alertController,
animated: true,
completion: nil)
Возврат к списку