iOSApplicationTemplate
iOSApplicationTemplate copied to clipboard
접근성
https://github.com/cashapp/AccessibilitySnapshot
https://twitter.com/JamesSherlouk/status/1534607524862865411?s=20&t=ZyiVW3ff8aqZehlyefnFFQ
https://gist.github.com/Sherlouk/f3956b440333084ef9ea1e505856500c
https://github.com/banksalad/AXSnapshot
import SwiftUI
import UIKit
// from https://github.com/cashapp/AccessibilitySnapshot
import AccessibilitySnapshotCore
struct AccessibilityPreview<Content: View>: View {
let content: Content
var body: some View {
AccessibilityPreviewRepresentable(content: content)
.previewLayout(.fixed(
width: UIScreen.main.bounds.width * 2,
height: UIScreen.main.bounds.height
))
.previewDisplayName("VoiceOver Representation")
}
}
private struct AccessibilityPreviewRepresentable<Content: View>: UIViewRepresentable {
let content: Content
func makeUIView(context: Context) -> some UIView {
let view = UIHostingController(rootView: content)
view.view.frame = UIScreen.main.bounds
let snapshotView = AccessibilitySnapshotView(
containedView: view.view,
viewRenderingMode: .drawHierarchyInRect,
activationPointDisplayMode: .whenOverridden
)
// who needs error management 'eh?
try! snapshotView.parseAccessibility(useMonochromeSnapshot: false)
return snapshotView
}
func updateUIView(_ uiView: UIViewType, context: Context) {}
}