Я пытался использовать сборщик внутри меню (потому что я хочу, чтобы у лейбла не было изображения) и применить. Нет результата, и я начинаю думать, что это невозможно или не легко сделать. Вот мой текущий код. Спасибо. < /P>
Код: Выделить всё
Menu {
Picker("", selection: vm.$selectedColor) {
ForEach(colorOptions.allCases) { option in
Label(option.rawValue.capitalized, systemImage: "circle.fill")
.foregroundColor(option.color)
.tag(option)
}
}
} label: {
Text("Select color")
}
< /code>
ColorOptions:enum colorOptions: String, CaseIterable, Identifiable {
var id: String { self.rawValue }
case indigo
case red
case green
case blue
case yellow
case orange
case purple
var color: Color {
switch self {
case .indigo: return .indigo
case .red: return .red
case .green: return .green
case .blue: return .blue
case .yellow: return .yellow
case .orange: return .orange
case .purple: return .purple
}
}
}
< /code>
Note that these are not the colors i want to use those were for testing the picker
Подробнее здесь: https://stackoverflow.com/questions/790 ... ide-picker
Мобильная версия