實例方法
border(_:
border(_:width:)
使用指定的樣式和寬度向此視圖添加邊框。
聲明
func border<S>(
_ content: S,
width: CGFloat = 1
) -> some View where S : ShapeStyle
返回值
向此視圖添加具有指定樣式和寬度的邊框的視圖。
參數
content
符合
ShapeStyle
協議的值,如Color
或HierarchicalShapeStyle
,SwiftUI 用於填充邊框。width
邊框的粗細。默認值為 1 像素。
詳述
使用此修飾符在視圖框架周圍繪製指定寬度的邊框。默認情況下,邊框出現在此視圖的邊界內。例如,您可以添加一個four-point 寬邊框覆蓋文本:
Text("Purple border inside the view bounds.")
.border(Color.purple, width: 4)
要在此視圖的外部放置邊框,請在添加邊框之前應用相同寬度的填充:
Text("Purple border outside the view bounds.")
.padding(4)
.border(Color.purple, width: 4)
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Never body用法及代碼示例
- Swift Never badge(_:)用法及代碼示例
- Swift Never buttonStyle(_:)用法及代碼示例
- Swift Never background(_:ignoresSafeAreaEdges:)用法及代碼示例
- Swift Never brightness(_:)用法及代碼示例
- 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 background(ignoresSafeAreaEdges:)用法及代碼示例
- 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 border(_:width:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。