Я хочу добавить изображение в функцию CPAlertTemplate Apple CarPlay по умолчанию.
Вот мой код:Я хочу добавить изображение вместе с заголовком и описанием оповещения.
Заголовок
func updateCarPlayTemplate(title: String) {
guard let interfaceController = carPlayInterfaceController else { return }
// Dismiss any existing template
interfaceController.dismissTemplate(animated: false) {, in
// Define the title and description
let title = title
// Define the title variants to include the description
let titleVariants = [title]
// Define the actions
let okAction = CPAlertAction(title: "OK", style: .default) { action in
// Handle OK action
interfaceController.dismissTemplate(animated: true, completion: nil)
}
// Create and present the alert template
let alertTemplate = CPAlertTemplate(titleVariants: titleVariants, actions: [okAction])
interfaceController.presentTemplate(alertTemplate, animated: true)
// Dismiss the template automatically after 3 seconds
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
interfaceController.dismissTemplate(animated: true, completion: nil)
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... rttemplate
Apple CarPlay добавляет изображение в оповещение (CPAlertTemplate) ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение