Set the font for UIDatePicker in iOS10 with Swift 3

冷暖自知 提交于 2019-12-08 10:20:29

问题


Is there is a public interface to set the font for a UIDatePicker in Swift 3?

I am well aware that similar questions have been asked, mainly asking about how to change the color of labels inside a UIDatePicker.

Using something like datePicker.setValue(UIColor.someColor, forKey: "textColor") is accessing a private property, which could raise some eyebrows.

And using appearanceWhenContainedIn doesn't expose neither the label's textColor nor its font:

UILabel.appearance(whenContainedInInstancesOf: [UIDatePicker.self]).???

So, is there a formal way of changing the font of a UIDatePicker? Or should I build a date picker from scratch?


回答1:


So, is there a formal way of changing the font of a UIDatePicker?

No, there isn't. That is exactly why all these workarounds are proposed.



来源:https://stackoverflow.com/questions/41793097/set-the-font-for-uidatepicker-in-ios10-with-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!