swift uiでpickerを使いユーザーに選択肢の中から一つを選んで貰うコードを書いています。
選択中の選択肢や矢印の色を黒くしたいのですが初期の青から変えられません。foregroundcolorやcolorなど色々試してみたのですが全部効果はありませんでした。
下記の写真の選択肢の青い部分の色を変える方法を教えて頂けると幸いです。(出来れば隣の上下矢印も消したいです。)
swift
1 @State var select1 = 0 2 @State var position = ["投","捕","一","二","三","遊","左","中","右"] 3 @State var name1 = "" 4 @FocusState var isActive:Bool 5 6HStack{ 7 Text("1") 8 Picker(selection:$select1, label:Text("ポジション")){ 9 ForEach(0..<position.count,id: \.self){index in 10 Text(position[index]) 11 } 12 }.foregroundColor(.black) 13 TextField("選手",text: $name1) 14 .multilineTextAlignment(.center) 15 .textFieldStyle(RoundedBorderTextFieldStyle()) 16 .focused($isActive) 17 }.toolbar { // VStackに指定 18 ToolbarItemGroup(placement: .keyboard) { 19 Spacer() // 右寄せにする 20 Button("閉じる") { 21 isActive = false // フォーカスを外す 22 } 23 } 24 }.padding(.vertical,25).background(Color.gray) 25
回答2件
あなたの回答
tips
プレビュー