Changing text color of datepicker

前端 未结 8 2348
鱼传尺愫
鱼传尺愫 2020-12-01 15:57

Is it any way to change text color of datepicker in iOS8? I\'ve that it isn\'t possible in iOS7 and prior, something changed in 8th version?

For example I\'ve found

8条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 16:16

    Resolving the issue with black "Today" via highlightsToday set to "false" has a side-effect - it's no longer has "Today" label in the list.

    I've found a different solution here which works perfect without any side-effects: Set text color and font for UIDatePicker in iOS8/Swift

    datePicker.setValue(UIColor.whiteColor(), forKeyPath: "textColor")
    datePicker.datePickerMode = .CountDownTimer
    datePicker.datePickerMode = .DateAndTime //or whatever your original mode was
    

    Looks like a dirty hack but that's we have at the moment: changing datePickerMode re-draws it correctly. So just set it to something different from your desired mode and change it back to original.

提交回复
热议问题