實例方法
brightness(_:)
使該視圖變亮指定的量。
聲明
func brightness(_ amount: Double) -> some View
返回值
使該視圖變亮指定量的視圖。
參數
amount
一個介於 0(無效果)和 1(全白增亮)之間的值,表示亮度效果的強度。
詳述
使用brightness(_:)
來增加視圖中顏色的強度。下麵的示例顯示了一係列紅色方塊,它們的亮度以 20% 的增量從 0(全紅)到 100%(白色)增加。
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)
}
}
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Never badge(_:)用法及代碼示例
- Swift Never buttonStyle(_:)用法及代碼示例
- Swift Never background(_:ignoresSafeAreaEdges:)用法及代碼示例
- Swift Never background(in:fillStyle:)用法及代碼示例
- Swift Never blur(radius:opaque:)用法及代碼示例
- Swift Never blendMode(_:)用法及代碼示例
- Swift Never background(alignment:content:)用法及代碼示例
- Swift Never background(_:in:fillStyle:)用法及代碼示例
- Swift Never border(_:width:)用法及代碼示例
- Swift Never background(ignoresSafeAreaEdges:)用法及代碼示例
- Swift Never body用法及代碼示例
- 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:)用法及代碼示例
- Swift Never position(_:)用法及代碼示例
- Swift Never luminanceToAlpha()用法及代碼示例
- Swift Never accessibilityAction(_:_:)用法及代碼示例
- Swift Never previewDisplayName(_:)用法及代碼示例
- Swift Never progressViewStyle(_:)用法及代碼示例
- Swift Never popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never brightness(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。