Last active
September 28, 2021 02:09
-
-
Save dheerajn/0b1d717d6253a6334ead064c38fcd45e to your computer and use it in GitHub Desktop.
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 { | |
func debugOnlyModifier<T: View>(_ modifier: (Self) -> T) -> some View { | |
#if DEBUG | |
return modifier(self) | |
#else | |
return self | |
#endif | |
} | |
private var colors: [Color] { | |
[.blue, .yellow, .green, .red, .brown, .cyan, .gray, .indigo, .mint, .pink, .orange] | |
} | |
func debugOnlyBackground() -> some View { | |
debugOnlyModifier { | |
$0.background(Rectangle().foregroundColor(colors.randomElement())) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment