Skip to content

Instantly share code, notes, and snippets.

@rudrankriyam
Last active July 4, 2020 18:50
Show Gist options
  • Select an option

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

Select an option

Save rudrankriyam/e52deea1abea12e65ce1e12140d65aaa to your computer and use it in GitHub Desktop.
struct ToolbarButton: View {
var imageName: String
var accessibilityLabel: String
var accessibilityHint: String
var action: (()->()) = {}
var body: some View {
Button(action: action) {
Image(systemName: imageName)
.font(.headline)
.textCase(.none)
}
.accessibility(Label: Text(accessibilityLabel))
.help(accessibilityHint)
.padding(10)
.offset(x: 10)
.hoverEffect()
}
}
struct ExampleView: View {
var body: some View {
NavigationView {
Text("Hello I'm an example")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
ToolbarButton(imageName: "square.and.arrow.up", accessibilityLabel: "Share Card", accessibilityHint: "Open share sheet") {
// self.openSharing()
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment