我正在創建貨幣換算應用程序。貨幣應該選擇一個選擇器視圖,所有的數據已經在裏面。我的選擇器視圖字體目前是黑色的,但我想要它是白色的。我將如何改變字體的顏色(不是背景)?更改Picker View內的字體顏色
func numberOfComponents(in pickerView: UIPickerView) -> Int
{
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int
{
return pickerViewSource.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?
{
return pickerViewSource[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int
price_kind = pickerViewSource[row]
switch price_kind {
case "USD":
label.text = "$ " + price_kind
rate = 1.0
case "EUR":
label.text = "€ " + price_kind
rate = 0.9461
case "GBP":
label.text = "£ " + price_kind
rate = 0.8017
case "RUB":
label.text = "₽ " + price_kind
rate = 64.3435
case "CNY":
label.text = "¥ " + price_kind
rate = 6.9137
case "YEN":
label.text = "¥ " + price_kind
rate = 6.26
case "AUD":
label.text = "$ " + price_kind
rate = 1.3498
case "CAD":
label.text = "$ " + price_kind
rate = 1.3483
default:
label.text = "$ " + price_kind
rate = 1.0
}
** picker.backgroundColor = UIColor.white **其中** picker **是您的UIPIcker對象的引用。 – Wolverine