实例方法
color
colorMultiply(_:)
向此视图添加颜色倍增效果。
声明
func colorMultiply(_ color: Color) -> some View
返回值
具有颜色倍增效果的视图。
参数
color
偏向此视图的颜色。
详述
以下示例并排显示了同一图像的两个版本;左边是原件,右边是带有 colorMultiply(_:)
修饰符的副本,应用了 ShapeStyle/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)
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相关用法
- Swift Never colorInvert()用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代码示例
- Swift Never compositingGroup()用法及代码示例
- Swift Never contextMenu(menuItems:)用法及代码示例
- Swift Never cornerRadius(_:antialiased:)用法及代码示例
- Swift Never contentShape(_:_:eoFill:)用法及代码示例
- Swift Never coordinateSpace(name:)用法及代码示例
- Swift Never contrast(_:)用法及代码示例
- Swift Never controlSize(_:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:message:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:presenting:actions:message:)用法及代码示例
- Swift Never containerShape(_:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:presenting:actions:)用法及代码示例
- Swift Never clipShape(_:style:)用法及代码示例
- Swift Never clipped(antialiased:)用法及代码示例
- Swift Never pageCommand(value:in:step:)用法及代码示例
- Swift Never opacity(_:)用法及代码示例
- Swift Never accessibilityAction(action:label:)用法及代码示例
- Swift Never alert(isPresented:error:actions:message:)用法及代码示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代码示例
- Swift Never position(x:y:)用法及代码示例
- Swift Never position(_:)用法及代码示例
- Swift Never luminanceToAlpha()用法及代码示例
- Swift Never accessibilityAction(_:_:)用法及代码示例
- Swift Never previewDisplayName(_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Never colorMultiply(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。