实例方法
control
controlSize(_:)
设置此视图中控件的大小。
声明
func controlSize(_ controlSize: ControlSize) -> some View
参数
controlSize
ControlSize
枚举中指定的控件大小之一。
详述
使用controlSize(_:)
覆盖此视图中控件的系统默认大小。在此示例中,视图以 .mini
、 .small
和 .regular
大小显示几个典型控件。
struct ControlSize: View {
var body: some View {
VStack {
MyControls(label: "Mini")
.controlSize(.mini)
MyControls(label: "Small")
.controlSize(.small)
MyControls(label: "Regular")
.controlSize(.regular)
}
.padding()
.frame(width: 450)
.border(Color.gray)
}
}
struct MyControls: View {
var label: String
@State private var value = 3.0
@State private var selected = 1
var body: some View {
HStack {
Text(label + ":")
Picker("Selection", selection: $selected) {
Text("option 1").tag(1)
Text("option 2").tag(2)
Text("option 3").tag(3)
}
Slider(value: $value, in: 1...10)
Button("OK") { }
}
}
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 10.15+, Mac Catalyst 15.0+, watchOS 9.0+ Beta
相关用法
- Swift Never contrast(_:)用法及代码示例
- Swift Never contextMenu(menuItems:)用法及代码示例
- Swift Never contentShape(_:_:eoFill:)用法及代码示例
- Swift Never containerShape(_:)用法及代码示例
- 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 controlSize(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。