WatchKit SF monospaced number

时间:2015-06-29 10:47:56

标签: ios objective-c swift watchkit xcode7

Is there any way to set monospaced for San Francisco font in WatchKit? In Introducing the New System Fonts, the presenter only shows for AppKit.

Sample code is appreciated.

Xcode: 7.0 beta WatchOS: 2.0

4 个答案:

答案 0 :(得分:4)

Swift版本:

{{1}}

答案 1 :(得分:3)

示例代码:

print()

答案 2 :(得分:0)

您需要将char *str = (char *)sqlite3_column_text(sqlStatement, 0); lyricyey.username = [NSString stringWithUTF8String:str ? str : ""]; 用于Apple Watch ..

  

Apple Watch使用旧金山紧凑型的两种变体:显示器   和文字。这些字体专为易读性而设计   小屏幕。

有关详细信息,请参阅此link.

SF Compact部分

答案 3 :(得分:0)

Swift 4

extension WKInterfaceLabel {
    func setMonospacedText(_ text: String) {
        let monospacedFont = UIFont.monospacedDigitSystemFont(ofSize: 16, weight: UIFont.Weight.regular)
        let attributedString = NSAttributedString(string: text, attributes: [NSAttributedStringKey.font: monospacedFont])
        self.setAttributedText(attributedString)
    }
}