實例方法
saturation(_:)
調整此視圖的色彩飽和度。
聲明
func saturation(_ amount: Double) -> some View
返回值
調整此視圖飽和度的視圖。
參數
amount
應用於此視圖的飽和度。
詳述
使用顏色飽和度來增加或減少視圖中顏色的強度。
下麵的示例顯示了一係列紅色方塊,它們的飽和度以 20% 的增量從 0(灰色)增加到 100%(fully-red):
struct Saturation: View {
var body: some View {
HStack {
ForEach(0..<6) {
Color.red.frame(width: 60, height: 60, alignment: .center)
.saturation(Double($0) * 0.2)
.overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%"),
alignment: .bottom)
.border(Color.gray)
}
}
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Never safeAreaInset(edge:alignment:spacing:content:)用法及代碼示例
- Swift Never simultaneousGesture(_:including:)用法及代碼示例
- Swift Never symbolVariant(_:)用法及代碼示例
- Swift Never scaledToFill()用法及代碼示例
- Swift Never searchCompletion(_:)用法及代碼示例
- Swift Never sheet(isPresented:onDismiss:content:)用法及代碼示例
- Swift Never submitScope(_:)用法及代碼示例
- Swift Never scaleEffect(x:y:anchor:)用法及代碼示例
- Swift Never speechAlwaysIncludesPunctuation(_:)用法及代碼示例
- Swift Never submitLabel(_:)用法及代碼示例
- Swift Never sheet(item:onDismiss:content:)用法及代碼示例
- Swift Never scaleEffect(_:anchor:)用法及代碼示例
- Swift Never scaledToFit()用法及代碼示例
- Swift Never shadow(color:radius:x:y:)用法及代碼示例
- Swift Never swipeActions(edge:allowsFullSwipe:content:)用法及代碼示例
- Swift Never suggestedFileName(_:)用法及代碼示例
- Swift Never scenePadding(_:)用法及代碼示例
- Swift Never pageCommand(value:in:step:)用法及代碼示例
- Swift Never opacity(_:)用法及代碼示例
- Swift Never colorMultiply(_:)用法及代碼示例
- Swift Never accessibilityAction(action:label:)用法及代碼示例
- Swift Never alert(isPresented:error:actions:message:)用法及代碼示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代碼示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代碼示例
- Swift Never position(x:y:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never saturation(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。