實例方法
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(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。