简体   繁体   中英

Set the font for UIDatePicker in iOS10 with Swift 3

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM