實例方法
preview
previewLayout(_:)
覆蓋預覽容器的大小。
聲明
func previewLayout(_ value: PreviewLayout) -> some View
返回值
使用給定布局的預覽。
參數
value
用於預覽的布局。
詳述
默認情況下,預覽使用 PreviewLayout/device
布局,它將視圖放置在所選設備的可視化表示中。您可以通過選擇 PreviewLayout
值之一來告訴預覽使用不同的布局,例如 PreviewLayout/sizeThatFits
:
struct CircleImage_Previews: PreviewProvider {
static var previews: some View {
CircleImage()
.previewLayout(.sizeThatFits)
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Never previewDisplayName(_:)用法及代碼示例
- Swift Never previewDevice(_:)用法及代碼示例
- Swift Never previewInterfaceOrientation(_:)用法及代碼示例
- Swift Never preferredColorScheme(_:)用法及代碼示例
- Swift Never prefersDefaultFocus(_:in:)用法及代碼示例
- Swift Never progressViewStyle(_:)用法及代碼示例
- Swift Never projectionEffect(_:)用法及代碼示例
- Swift Never privacySensitive(_:)用法及代碼示例
- Swift Never pageCommand(value:in:step:)用法及代碼示例
- Swift Never position(x:y:)用法及代碼示例
- Swift Never position(_:)用法及代碼示例
- Swift Never popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Never padding(_:_:)用法及代碼示例
- Swift Never popover(item:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Never padding(_:)用法及代碼示例
- 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 luminanceToAlpha()用法及代碼示例
- Swift Never accessibilityAction(_:_:)用法及代碼示例
- Swift Never badge(_:)用法及代碼示例
- Swift Never buttonStyle(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never previewLayout(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。