colorMultiply(_:)
Adds a color multiplication effect to this view.
Declaration
nonisolated func colorMultiply(_ color: Color) -> some View
Parameters
- color:
The color to bias this view toward.
Return Value
A view with a color multiplication effect.
Discussion
The following example shows two versions of the same image side by side; at left is the original, and at right is a duplicate with the colorMultiply(_:) modifier applied with purple.
struct InnerCircleView: View {
var body: some View {
Circle()
.fill(Color.green)
.frame(width: 40, height: 40, alignment: .center)
}
}
struct ColorMultiply: View {
var body: some View {
HStack {
Color.red.frame(width: 100, height: 100, alignment: .center)
.overlay(InnerCircleView(), alignment: .center)
.overlay(Text("Normal")
.font(.callout),
alignment: .bottom)
.border(Color.gray)
Spacer()
Color.red.frame(width: 100, height: 100, alignment: .center)
.overlay(InnerCircleView(), alignment: .center)
.colorMultiply(Color.purple)
.overlay(Text("Multiply")
.font(.callout),
alignment: .bottom)
.border(Color.gray)
}
.padding(50)
}
}[Image]