Instance Method インスタンスメソッド

colorMultiply(_:)

Adds a color multiplication effect to this view. 色乗算効果をこのビューに加えます。

Declaration 宣言

func colorMultiply(_ color: Color) -> some View

Return Value 戻り値

A view with a color multiplication effect. ある色乗算効果でのあるビュー。

Parameters パラメータ

color

The color to bias this view toward. このビューをそれへと偏らせることになる色。

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)
    }
}

A screenshot showing two images showing the effect of multiplying the