實例方法
horizontal
horizontalRadioGroupLayout()
將此視圖中的單選組樣式選擇器的樣式設置為與布局內的單選按鈕水平定位。
聲明
func horizontalRadioGroupLayout() -> some View
詳述
使用horizontalRadioGroupLayout()
配置Picker
中單選按鈕的視覺布局,以便單選按鈕在視圖中水平排列。
下麵的示例顯示了配置為單選按鈕組的兩個 Picker
控件;第一組顯示默認的垂直布局;第二組顯示了horizontalRadioGroupLayout()
的效果,它水平呈現單選按鈕。
struct HorizontalRadioGroupLayout: View {
@State private var selected = 1
var body: some View {
VStack(spacing: 20) {
Picker(selection: $selected, label: Text("Favorite Color")) {
Text("Red").tag(1)
Text("Green").tag(2)
Text("Blue").tag(3)
Text("Other").tag(4)
}
.pickerStyle(.radioGroup)
Picker(selection: $selected, label: Text("Favorite Color")) {
Text("Red").tag(1)
Text("Green").tag(2)
Text("Blue").tag(3)
Text("Other").tag(4)
}
.pickerStyle(.radioGroup)
.horizontalRadioGroupLayout()
}
.padding(20)
.border(Color.gray)
}
}
可用版本
macOS 10.15+
相關用法
- Swift Optional hidden()用法及代碼示例
- Swift Optional highPriorityGesture(_:including:)用法及代碼示例
- Swift Optional help(_:)用法及代碼示例
- Swift Optional headerProminence(_:)用法及代碼示例
- Swift Optional hueRotation(_:)用法及代碼示例
- Swift Optional symbolVariant(_:)用法及代碼示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Optional mask(alignment:_:)用法及代碼示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代碼示例
- Swift Optional badge(_:)用法及代碼示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代碼示例
- Swift Optional keyboardType(_:)用法及代碼示例
- Swift Optional clipShape(_:style:)用法及代碼示例
- Swift Optional preferredColorScheme(_:)用法及代碼示例
- Swift Optional background(_:ignoresSafeAreaEdges:)用法及代碼示例
- Swift Optional saturation(_:)用法及代碼示例
- Swift Optional focusSection()用法及代碼示例
- Swift Optional overlay(alignment:content:)用法及代碼示例
- Swift Optional colorMultiply(_:)用法及代碼示例
- Swift Optional confirmationDialog(_:isPresented:titleVisibility:presenting:actions:message:)用法及代碼示例
- Swift Optional offset(_:)用法及代碼示例
- Swift Optional focused(_:equals:)用法及代碼示例
- Swift Optional previewDevice(_:)用法及代碼示例
- Swift Optional keyboardShortcut(_:modifiers:localization:)用法及代碼示例
- Swift Optional imageScale(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional horizontalRadioGroupLayout()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。