Created
July 31, 2023 16:13
-
-
Save agiletortoise/ba276c346b6528bee62235a48860d7aa to your computer and use it in GitHub Desktop.
Useful way to provide backward compatible widget backgrounds
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 View { | |
@ViewBuilder | |
func widgetBackground<V>(@ViewBuilder content: () -> V) -> some View where V : View { | |
if #available(macOSApplicationExtension 14.0, iOSApplicationExtension 17.0, *) { | |
containerBackground(for: .widget) { | |
content() | |
} | |
} else { | |
background { | |
content() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment