Swiftui Picker
作者:
王勋才 | 来源:发表于
2021-11-18 20:44 被阅读0次//
// ContentView.swift
// SwiftUIPL
//
// Created by wangxuncai on 2021/11/18.
//
import SwiftUI
struct ContentView: View {
@State private var selection = "紫色"
let colors = ["棕","紫色", "蓝色", "红色", "黑色", "橙色"]
var body: some View {
NavigationView {
Form {
Picker("选择背景颜色", selection: $selection) {
ForEach(colors, id: \.self) {
Text($0)
.frame(maxWidth:.infinity,alignment: .leading)
.foregroundColor($0 == selection ? Color.blue : Color.black)
}
}
.pickerStyle(.inline)
}
.navigationTitle("设置")
}
}
}
IMG_1484.jpg
本文标题:Swiftui Picker
本文链接:https://www.haomeiwen.com/subject/fwsjtrtx.html
网友评论