Last active
April 4, 2023 15:44
-
-
Save passatgt/b05faa1b0cb5e9b52931cb53dac37e26 to your computer and use it in GitHub Desktop.
Custom ShortcutsLink in your SwiftUI Form
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
@Environment(\.colorScheme) var colorScheme | |
Form { | |
ZStack(alignment:.bottomLeading) { | |
Text("Custom Shortcuts Button") | |
HStack(spacing:0) { | |
ShortcutsLink().shortcutsLinkStyle((colorScheme == .dark) ? .dark : .light).frame(height: 20).opacity(0.011) | |
ShortcutsLink().shortcutsLinkStyle((colorScheme == .dark) ? .dark : .light).frame(height: 20).opacity(0.011) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The built-in ShortcutsLink() button looks out of place, but theres no way to modify it. This is a hacky way to solve the problem. Create a new row on a Form using a ZStack, so the ShortcutsLink will overlay the actual button you can design your own way. The lowest opacity that still work in my testing was 0.011. Two ShortcutsLink, so it covers the whole row. Looks like this in my case:
It will use the dark version in dark mode and the light version in light mode, so you really need to play close attention to notice it.