使用 Swift 3 在 iOS10 中设置 UIDatePicker 的字体 [英] Set the font for UIDatePicker in iOS10 with Swift 3

查看:54
本文介绍了使用 Swift 3 在 iOS10 中设置 UIDatePicker 的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift 3 中是否有为 UIDatePicker 设置 字体 的公共接口?

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

我很清楚有人问过类似的问题,主要是问如何更改 UIDatePicker 中标签的颜色.

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

使用诸如 datePicker.setValue(UIColor.someColor, forKey: "textColor") 之类的东西会访问私有属性,这可能会引起一些人的注意.

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

并且使用 appearanceWhenContainedIn 既不会暴露标签的 textColor 也不会暴露其字体:

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

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

那么,有没有一种正式的方式来改变UIDatePicker的字体?还是应该从头开始构建日期选择器?

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

推荐答案

那么,有没有一种正式的方式来改变 UIDatePicker 的字体?

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.

这篇关于使用 Swift 3 在 iOS10 中设置 UIDatePicker 的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆