How do I change the text color of UIPickerView with multiple components in Swift?

后端 未结 3 1545
天涯浪人
天涯浪人 2020-12-15 19:19

Below code will change the font colour of the picker view of all 3 components. However, it crash when I try to spin the wheel. I think it has to do with the didSelectRow f

3条回答
  •  有刺的猬
    2020-12-15 20:10

    Swift 3

    func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
            let attributedString = NSAttributedString(string: "YOUR STRING", attributes: [NSForegroundColorAttributeName : UIColor.white])
            return attributedString
        }
    

提交回复
热议问题