當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Swift Never hueRotation(_:)用法及代碼示例

實例方法

hueRotation(_:)

對此視圖應用色調旋轉效果。

聲明

func hueRotation(_ angle: Angle) -> some View

返回值

將色調旋轉效果應用到此視圖的視圖。

參數

angle

應用於此視圖中顏色的色調旋轉角度。

詳述

使用色調旋轉效果根據您指定的角度移動視圖中的所有顏色。

下麵的示例顯示了一係列填充有線性漸變的正方形。每個正方形顯示 36˚ hueRotation(5 個正方形總共 180˚)對漸變的影響:


struct HueRotation: View {
    var body: some View {
        HStack {
            ForEach(0..<6) {
                Rectangle()
                    .fill(.linearGradient(
                        colors: [.blue, .red, .green],
                        startPoint: .top, endPoint: .bottom))
                    .hueRotation((.degrees(Double($0 * 36))))
                    .frame(width: 60, height: 60, alignment: .center)
            }
        }
    }
}

可用版本

iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+

相關用法


注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never hueRotation(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。