Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created July 18, 2020 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/20496a89adf57c45f66eb1a72c23ea0a to your computer and use it in GitHub Desktop.
Save sturdysturge/20496a89adf57c45f66eb1a72c23ea0a to your computer and use it in GitHub Desktop.
RevDoc prefersDefaultFocus
import SwiftUI
@available(iOS, unavailable)
@available(OSX, unavailable)
@available(tvOS 14.0, *)
@available(watchOS 6.0, *)
struct ContentView: View {
@Namespace var namespace
var body: some View {
VStack {
Button("Usually the default"){
print("Top button pressed")
}
Button("Prefers default"){
print("Bottom button pressed")
}
.prefersDefaultFocus(in: namespace)
}
.focusScope(namespace)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment