// Button Shapes
func observeButtonShapesNotification() {
// Make buttons more visible by using shapes.
// If your default design does not include button shapes, observe this notification to make visual changes.
NotificationCenter.default.addObserver(self, selector: #selector(updateButtonShapes), name: UIAccessibility.buttonShapesEnabledStatusDidChangeNotification, object: nil)
}
@objc func updateButtonShapes() {
if UIAccessibility.buttonShapesEnabled {
// Use extra visualizations for buttons.
} else {
// Use default design for buttons.
}
}
// Differentiate Without Color
func observeDifferentiateWithoutColorNotification() {
// Use symbols or shapes to convey meaning instead of relying on color alone.
// If your default design does not differentiate without color, observe this notification to make visual changes.
NotificationCenter.default.addObserver(self, selector: #selector(updateColorAndSymbols), name: NSNotification.Name(UIAccessibility.differentiateWithoutColorDidChangeNotification), object: nil)
}
@objc func updateColorAndSymbols() {
if UIAccessibility.shouldDifferentiateWithoutColor {
// Use symbols or shapes to convey meaning.
} else {
// Use default design.
}
}
// Smart Invert Colors
extension UIView {
@available(iOS 11.0, tvOS 11.0)
var accessibilityIgnoresInvertColors: Bool { get set }
}
テキストの読みやすさについて
アプリデザインでは、文字をくっきりと読みやすくするよう留意する
Bold設定と活用したテキストの強調デザイン
// 大きなテキストの設定
// 画面上で表示が調整されると呼び出される
override func traitCollectionDidChange (_ previousTraitCollection: UITraitCollection?) {
if (traitCollection.preferredContentSizeCategory
< .accessibilityMedium) { // Default font sizes
stackView.axis = .horizontal
stackView.alignment = .center
} else { // Accessibility font sizes
// ディスプレイの幅を最大限利用したラベル表示が可能
stackView.axis = .vertical
stackView.alignment = .leading
}
}
// 太文字の設定
func observeBoldTextNotification() {
// Update labels to use bold or heavy font styles.
// If you aren't using system font styles, observe this notification to make visual changes.
NotificationCenter.default.addObserver(self, selector: #selector(updateLabelWeight), name: UIAccessibility.boldTextStatusDidChangeNotification, object: nil)
}
@objc func updateLabelWeight() {
if UIAccessibility.isBoldTextEnabled {
// Use bold or heavy font weight
} else {
// Use font weight that is default to your design.
}
}
// モーションエフェクトの抑制
func observeReduceMotionNotification() {
// Observe this notification to reduce or remove the frequency and intensity of motion effects.
NotificationCenter.default.addObserver(self, selector: #selector(updateMotionEffects), name: UIAccessibility.reduceMotionStatusDidChangeNotification, object: nil)
}
@objc func updateMotionEffects() {
if UIAccessibility.isReduceMotionEnabled {
// Reduce or remove extraneous motion effects.
} else {
// Use default motion effects.
}
}
// Prefer cross fade transitionsの実装
func observeCrossFadeTransitionsNotification() {
// Reduce or remove sliding animations for transitioning views.
// If you aren't using system-provided navigation, observe this notification to make visual changes.
NotificationCenter.default.addObserver(self, selector: #selector(updateTransitionEffects), name: UIAccessibility.prefersCrossFadeTransitionsStatusDidChange, object: nil)
}
@objc func updateTransitionEffects() {
if UIAccessibility.prefersCrossFadeTransitions {
// Replace sliding transitions with cross-fade animations.
} else {
// Use default sliding transitions.
}
}
// Reduce Transparencyの設定通知実装
func observeReduceTransparencyNotification() {
// Reduce or remove transparency by adjusting these effects to be completely opaque.
// If you aren't using system-provided visual effects for blurs or vibrancy, observe this notification to make visual changes.
NotificationCenter.default.addObserver(self, selector: #selector(updateTransparencyEffects), name: UIAccessibility.reduceTransparencyStatusDidChangeNotification, object: nil)
}
@objc func updateTransparencyEffects() {
if UIAccessibility.isReduceTransparencyEnabled {
// Make transparency effects opaque.
} else {
// Use default transparency.
}
}