Last active
June 29, 2020 21:22
-
-
Save renataporto/6f8085cfa6d147957e97186c68e7bbb9 to your computer and use it in GitHub Desktop.
Preparando o seu app para dar suporte aos recursos de acessibilidade visual disponíveis para usuários de iOS. Leia mais em https://bit.ly/cch-acessibilidade-visual
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fique à vontade para usar o código abaixo e dar a seus apps uma experiência visual inclusiva para todas as pessoas. | |
// Leia uma descrição sobre cada um desses recursos no link https://bit.ly/cch-acessibilidade-visual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func observeBoldTextNotification() { | |
// Observe essa notificação para saber se a configuração está ativa e fazer mudanças no layout. | |
NotificationCenter.default.addObserver(self, selector: #selector(updateLabelWeight), name: UIAccessibility.boldTextStatusDidChangeNotification, object: nil) | |
} | |
@objc func updateLabelWeight() { | |
if UIAccessibility.isBoldTextEnabled { | |
// Aqui, use fontes com pesos maiores, como bold ou heavy. | |
} else { | |
// Aqui, use o peso de fonte padrão do seu layout. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func observeDifferentiateWithoutColorNotification() { | |
// Observe essa notificação para saber se a configuração está ativa e fazer mudanças no layout. | |
NotificationCenter.default.addObserver(self, selector: #selector(updateColorAndSymbols), name: NSNotification.Name(UIAccessibility.differentiateWithoutColorDidChangeNotification), object: nil) | |
} | |
@objc func updateColorAndSymbols() { | |
if UIAccessibility.shouldDifferentiateWithoutColor { | |
// Aqui, adicione símbolos e formas às suas views, para dar significado aos elementos da sua interface. | |
} else { | |
// Aqui, sete o layout padrão. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func traitCollectionDidChange (_ previousTraitCollection: UITraitCollection?) { | |
if (traitCollection.preferredContentSizeCategory | |
< .accessibilityMedium) { // Fontes com tamanho padrão | |
// Aqui, sete o layout adequado para fontes no tamanho padrão. | |
} else { // Fontes com tamanhos acessíveis | |
// Aqui, sete o layout adaptado para fontes no tamanho maior. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func observeCrossFadeTransitionsNotification() { | |
// Observe essa notificação para saber se a configuração está ativa e fazer alterações nas transições do seu app. | |
NotificationCenter.default.addObserver(self, selector: #selector(updateTransitionEffects), name: UIAccessibility.prefersCrossFadeTransitionsStatusDidChange, object: nil) | |
} | |
@objc func updateTransitionEffects() { | |
if UIAccessibility.prefersCrossFadeTransitions { | |
// Aqui, substitua animações de deslize por animações de cross-fade. | |
} else { | |
// Aqui, use as animações padrão do seu app. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func observeReduceMotionNotification() { | |
// Observe essa notificação para saber se a configuração está ativa e suavizar ou remover a frequência e intensidade das animações. | |
NotificationCenter.default.addObserver(self, selector: #selector(updateMotionEffects), name: UIAccessibility.reduceMotionStatusDidChangeNotification, object: nil) | |
} | |
@objc func updateMotionEffects() { | |
if UIAccessibility.isReduceMotionEnabled { | |
// Aqui, ofereça alternativas com menos efeitos de movimento. | |
} else { | |
// Aqui, sete as configurações padrão de animações do seu app. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func observeReduceTransparencyNotification() { | |
// Observe essa notificação para saber se a configuração está ativa e atualizar os efeitos de transparência do seu app. | |
NotificationCenter.default.addObserver(self, selector: #selector(updateTransparencyEffects), name: UIAccessibility.reduceTransparencyStatusDidChangeNotification, object: nil) | |
} | |
@objc func updateTransparencyEffects() { | |
if UIAccessibility.isReduceTransparencyEnabled { | |
// Aqui, adapte os efeitos de transparência para alternativas opacas, com cores sólidas | |
} else { | |
// Aqui, use os efeitos padrão de transparência/blur | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Criando UIImages a partir de SF Symbols | |
let shuffleImage = UIImage(systemName: "shuffle") // Você pode trocar shuffle por qualquer outra referência | |
// Combinando texto com SF Symbols em SwiftUI | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
Label("Sharing location", | |
systemImage: "location.fill") // Você pode trocar location.fill por qualquer outra referência | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
@available(iOS 11.0, tvOS 11.0) | |
var accessibilityIgnoresInvertColors: Bool { get set } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Leia mais sobre cada um desses recursos no link https://bit.ly/cch-acessibilidade-visual