此包能帮助您更容易地理解您的应用程序设计对具有各种色盲类型的用户的影响。
它为 SnapshotTesting 添加了功能,使您能够生成 UIViews、UIViewControllers 和 UIImages 的图像,并叠加多种色盲滤镜,模拟具有不同视觉缺陷的用户看到的效果。
// 1. Import
import AccessibilitySnapshotColorBlindness
// 2. Create UIView, UIViewController or UIImage.
let systemUnderTest = // ... your code
// 3. Assert Snapshot
assertSnapshot(matching: image, as: .image_colourBlindness(type: .protanopia))
您可能希望使用 MatrixTypes.allCases
来快照您视图的所有变体。 您可以在我们的测试中看到一个示例。