iOS 응용 (swift)
[iOS - swift] 4. VoiceOver 접근성 실전 - UIAccessibility Notification (post, 노티)
jake-kim
2023. 9. 5. 01:01
1. VoiceOver 접근성 실전 - 개발 시작하기 (손쉬운 사용 단축키, Accessibility Inspector, 테스트)
3. VoiceOver 접근성 실전 - 접근성 처리 (순서 처리, 이미지 인식, accessibility label, value, traits, hint 사용)
4. VoiceOver 접근성 실전 - UIAccessibility Notification (post, 노티)
5. VoiceOver 접근성 실전 - 접근성 계층관계
UIAccessibility Notification
- 접근성도 특정 뷰를 탭하지 않고, 토스트가 노출되거나 사용자에게 특정 알림을 VoiceOver로 알려주어야 하는 경우 노티가 가능

- 코드로 아래처럼 보이스 오버가 활성화 되어 있을 때 (isVoiceOverRunning) UIAccesibility.post로 사용 가능
- isVoiceOverRunning가 켜져 있지 않았을때 UIAccesibility.post를 사용해도 보이스 오버가 동작하지 않지만, 보이스 오버가 활성화되지 않은 상태에서는 UIAccessibility.post를 호출해도 동작하지 않으므로 호출 비용을 줄이기 위함
accessibilityPostButton.addTarget(self, action: #selector(postNoti), for: .touchUpInside)
private func postNoti() {
guard UIAccessibility.isVoiceOverRunning else { return }
UIAccessibility.post(notification: .screenChanged, argument: "노티 샘플")
}
notification 타입
- 위에서는 screenChanged라는 notification 타입을 사용했는데 이외에 총 6가지 타입이 존재
extension UIAccessibility.Notification {
public static var screenChanged: UIAccessibility.Notification
public static var layoutChanged: UIAccessibility.Notification
@available(iOS 4.0, *)
public static var announcement: UIAccessibility.Notification
@available(iOS 4.2, *)
public static var pageScrolled: UIAccessibility.Notification
@available(iOS 8.0, *)
public static var pauseAssistiveTechnology: UIAccessibility.Notification
@available(iOS 8.0, *)
public static var resumeAssistiveTechnology: UIAccessibility.Notification
}
- 노티 타입
- screenChanged: 화면이 변경될 때 발생 (새로운 뷰 컨트롤러 표시, 토스트 뷰 표시)
- layoutChanged: 레이아웃 변경
- announcement: 앱에서 중요한 정보나 공지를 읽어 주는 접근성 알림
- pageScrolled: 페이지 스크롤이 발생할 때 발생하는 접근성 알림
- pauseAssistiveTechnology: *Assistive Technology 사용을 일시 중단하는 알림
- resumeAssistiveTechnology: *Assistive Technology 사용을 다시 시작하는 알림
* Assistive Technology: 접근성을 위해 애플에서 사용하는 VoiceOver와 같은 것들을 의미
- pauseAssistiveTechnology와 resumeAssistiveTechnology 예시
- pauseAssistiveTechnology: 음성 메모앱에서, VoiceOver가 특정 문구에 관해 설명하는 도중에 녹음 버튼을 탭한 경우 "VoiceOver가 일시 중단되었습니다. 녹음을 시작하세요."라는 노티
- resumeAssistiveTechnology: 음성 메모앱에서, 녹음이 끝나고 나서 다시 VoiceOver 알림을 주고 싶은 경우, "VoiceOver가 다시 활성화 되었습니다."라는 노티
* 전체 코드: https://github.com/JK0369/ExAccessibility
* 참고
https://developer.apple.com/documentation/uikit/uiaccessibility/notification