I added a shimmer effect for my home screen like the code below.
VStack{
TopView()
HomeView()
}
.redacted(.placeholder)
I got the output like the below image.
the shimmer view showing color for the colored view but the normal view shows gray colored.
can i change the whole shimmer view into gray color without showing the colored view in shimmer?
One approach might be to adjust your custom subviews to respond to whether they're being asked to display as a redaction.
For example, if you have a view that adds a piece of text within a red background, e.g.:
struct LabelView: View {
var text: String
var body: some View {
Text(text)
.padding()
.background(Color.red)
}
}
you could then adapt it to use grey when being redacted:
struct LabelView: View {
@Environment(\.redactionReasons) var redactionReasons
var text: String
var body: some View {
Text(text)
.padding()
.background(redactionReasons.contains(.placeholder) ? Color.gray : Color.red)
}
}