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

brightness(_:)

Brightens this view by the specified amount. このビューをこの指定された量だけ明るくします。

Declaration 宣言

func brightness(_ amount: Double) -> some View

Return Value 戻り値

A view that brightens this view by the specified amount. あるビュー、それはこのビューをその指定された量だけ明るくしたものです。

Parameters パラメータ

amount

A value between 0 (no effect) and 1 (full white brightening) that represents the intensity of the brightness effect. 0(影響なし)と1(完全に白く輝く)の間のある値、それは輝度効果の強さを表します。

Discussion 議論

Use brightness(_:) to brighten the intensity of the colors in a view. The example below shows a series of red squares, with their brightness increasing from 0 (fully red) to 100% (white) in 20% increments.


struct Brightness: View {
    var body: some View {
        HStack {
            ForEach(0..<6) {
                Color.red.frame(width: 60, height: 60, alignment: .center)
                    .brightness(Double($0) * 0.2)
                    .overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%"),
                             alignment: .bottom)
                    .border(Color.gray)
            }
        }
    }
}

Rendering showing the effects of brightness adjustments in 20%