ama*_*ain 5 uidatepicker uipickerview ios swift3
我有一个viewControllera UIPickerView和a UIDatePicker,storyboard如下面的截图所示.
我尝试添加属性运行时所解释这里.但是它只是改变了最初突出显示的文本的字体颜色.我想将pickerView和datePicker中的文本颜色更改为白色.我不知道如何实现它.
Jig*_*iya 11
你需要写这一行来改变日期选择器文本颜色,
self.datePicker.setValue(UIColor.white, forKeyPath: "textColor")
Run Code Online (Sandbox Code Playgroud)
它会改变文本颜色 UIDatePicker
而对于PickeView,你必须设置属性字符串,如,
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
return NSAttributedString(string: "Your Text", attributes: [NSForegroundColorAttributeName:UIColor.blue])
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3077 次 |
| 最近记录: |