AccessibilityNotification.Announcement
A notification that an app posts when it needs to convey an announcement to an assistive app.
Declaration
struct AnnouncementOverview
Include an announcement value, such as String or AttributedString, for an assistive app to announce.
Optionally, you can apply accessibility speech attributes to the announcement. For example, you can set a priority to specify the announcement’s importance relative to other announcements that are in the queue for an assistive app to speak. Announcement priorities give you more control over which announcements people need to hear, and which ones are acceptable to ignore or interrupt.
You specify an announcement priority using the accessibilitySpeechAnnouncementPriority property. The following code shows an example of how to post an announcement notification with a high priority, which interrupts other speech and isn’t interruptible after it starts:
import SwiftUI
var body: some View {
Button(action: {
// Load the camera.
openCamera()
// Post an announcement to indicate the camera is done loading.
var highPriorityAnnouncement = AttributedString("Camera active")
highPriorityAnnouncement.accessibilitySpeechAnnouncementPriority = .high
AccessibilityNotification.Announcement(highPriorityAnnouncement).post()
}) {
Image("Camera")
}
}