Change UIDatePicker font color?

后端 未结 15 1807
南方客
南方客 2020-12-04 19:12

All I want to do is change the font color of the UIDatePicker. I\'ve researched other questions but they\'re all involving changing other properties and customizing the enti

15条回答
  •  萌比男神i
    2020-12-04 20:04

    To change UIDatePicker text color use:

        // MARK: - Helping content 
    
        private enum DatePickerProperties: String {
            case TextColor = "textColor"
            case HighlightsToday = "highlightsToday"
        }
    
        // MARK: - Outlets
    
        @IBOutlet private weak var datePicker: UIDatePicker!
    
        // MARK: - Lifecicle
    
        public override func awakeFromNib() {
            super.awakeFromNib()
    
            self.datePicker.setValue(UIColor.whiteColor(), forKey: DatePickerProperties.TextColor.rawValue)
            self.datePicker.setValue(false, forKey: DatePickerProperties.HighlightsToday.rawValue)
        }
    

    It works like a charm with xCode 7.3 and Swift 2.3.

提交回复
热议问题