tim*_*ith 11 ios uistoryboard xcode-storyboard swift
如何使用动态类型文本样式 "Title 1"并将字体面设置为故事板中UILabel的内置字体Chalkboard SE?
我需要尊重iOS中的动态类型大小(Apple自iOS 7以来一直鼓励这样做吗?)我还需要使用内置字体Chalkboard SE,默认情况下它不用于"文本样式"字体.我目前正在使用图像中显示的自定义字体,但需要字体根据用户的动态类型/辅助功能大小首选项更改大小,就像所有文本样式字体一样.最佳文本样式选项是标题1,但字体/字体是不可接受的.
小智 19
虽然您无法通过Storyboard指定自定义字体和首选文本样式,但以编程方式为自定义字体指定动态类型大小并不困难:
迅速:
let pointSize = UIFontDescriptor.preferredFontDescriptorWithTextStyle(UIFont??TextStyleTitle1).poi??ntSize
let customFont = UIFont(name: "Chalkboard SE", size: pointSize)
Run Code Online (Sandbox Code Playgroud)
收到a时UIContentSizeCategoryDidChangeNotification,请使用相同的代码更新标签的字体.
对象C:
CGFloat pointSize = [[UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline] pointSize];
[titleLabel setFont:[UIFont fontWithName:@"Marker Felt" size:pointSize]];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6872 次 |
| 最近记录: |