a d*_*per 5 objective-c ios swift watchkit xcode7
有没有办法在WatchKit中为旧金山字体设置monospaced?在介绍新系统字体时,演示者仅显示AppKit.
示例代码表示赞赏.
Xcode:7.0 beta WatchOS:2.0
迅捷版:
let monospacedFont = UIFont.monospacedDigitSystemFontOfSize(16, weight: UIFontWeightRegular)
let monospacedString = NSAttributedString(string: "1234", attributes: [NSFontAttributeName: monospacedFont])
textLabel.setAttributedText(monospacedString)
Run Code Online (Sandbox Code Playgroud)
示例代码:
UIFont *systemFont = [UIFont systemFontOfSize:20];
UIFontDescriptor *monospacedNumberFontDescriptor = [systemFont.fontDescriptor fontDescriptorByAddingAttributes: @{
UIFontDescriptorFeatureSettingsAttribute: @[@{
UIFontFeatureTypeIdentifierKey: @6,
UIFontFeatureSelectorIdentifierKey: @0
}]
}];
UIFont *monospacedNumberSystemFont = [UIFont fontWithDescriptor:monospacedNumberFontDescriptor size:0];
NSMutableAttributedString *monospacedString = [[NSMutableAttributedString alloc] initWithString:@"1234567890"];
[monospacedString addAttribute:NSFontAttributeName value:monospacedNumberSystemFont range:NSMakeRange(0, monospacedString.string.length)];
[label setAttributedText:monospacedString];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
761 次 |
| 最近记录: |