Swiftui Picker

2021-11-18  本文已影响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
上一篇下一篇

猜你喜欢

热点阅读