Skip to content

Instantly share code, notes, and snippets.

@rudrankriyam
Created April 25, 2020 16:04
Show Gist options
  • Select an option

  • Save rudrankriyam/2607d8125c7d5c44157b19a2e65b48dc to your computer and use it in GitHub Desktop.

Select an option

Save rudrankriyam/2607d8125c7d5c44157b19a2e65b48dc to your computer and use it in GitHub Desktop.
A bar button with accessibility name
struct BarButtonView: View {
var imageName: String
var accessibilityName: String
var body: some View {
Image(systemName: imageName)
.resizable()
.font(.system(size: 25))
.foregroundColor(.primary)
.accessibility(label: Text(accessibilityName))
.frame(width: 25, height: 25, alignment: .trailing)
}
}
struct BarButtonView_Previews: PreviewProvider {
static var previews: some View {
BarButtonView(imageName: "gear", accessibilityName: "Settings")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment