实例方法
container
containerShape(_:)
设置容器形状以用于此视图中的任何容器相关形状。
声明
func containerShape<T>(_ shape: T) -> some View where T : InsettableShape
详述
下面的示例定义了一个视图,该视图以圆角矩形背景和相同的容器形状显示其内容。 content
中的任何 ContainerRelativeShape
都与此容器插图中的圆角矩形形状相匹配。
struct PlatterContainer<Content: View> : View {
@ViewBuilder var content: Content
var body: some View {
content
.padding()
.containerShape(shape)
.background(shape.fill(.background))
}
var shape: RoundedRectangle { RoundedRectangle(cornerRadius: 20) }
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
相关用法
- Swift Never contextMenu(menuItems:)用法及代码示例
- Swift Never contentShape(_:_:eoFill:)用法及代码示例
- Swift Never contrast(_:)用法及代码示例
- Swift Never controlSize(_:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:message:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:presenting:actions:message:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:presenting:actions:)用法及代码示例
- Swift Never colorMultiply(_:)用法及代码示例
- Swift Never compositingGroup()用法及代码示例
- Swift Never cornerRadius(_:antialiased:)用法及代码示例
- Swift Never colorInvert()用法及代码示例
- Swift Never coordinateSpace(name:)用法及代码示例
- 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 containerShape(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。