Hãy xem tại địa chỉ: http://makeapppie.com/tag/uipickerview-in-swift/
Nếu bạn muốn thay đổi màu sắc tiêu đề của bạn của mỗi yếu tố bạn có thể thực hiện:
func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = pickerData[row]
var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 15.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
return myTitle
}
Swift 3:
func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = pickerData[row]
let myTitle = NSAttributedString(string: titleData!, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 15.0)!,NSForegroundColorAttributeName:UIColor.white])
return myTitle
}
Nguồn
2015-03-25 08:53:12
Thay đổi màu sắc của những gì: font, nền, mục đã chọn, các mục không được chọn? –