【发布时间】:2015-08-31 22:08:49
【问题描述】:
我目前正在UILabel 上创建一个扩展,以方便观察动态类型。收到UIContentSizeCategoryDidChangeNotification 后,我希望我的选择器使用
self.font = UIFont.preferredFontForTextStyle(someUIFontTextStyle)
其中someUIFontTextStyle 使用与当前标签相同的UIFontTextStyle。我曾希望可以通过self.font.fontDescriptor.textStyle 之类的方式访问这样的属性,但事实似乎有点复杂。
有没有办法访问与UILabel 关联的UIFontTextStyle 属性?
解决方案
self.font.fontDescriptor().objectForKey(UIFontDescriptorTextStyleAttribute) as? String
【问题讨论】:
标签: ios iphone swift uilabel uifontdescriptor