【发布时间】:2018-07-16 04:23:38
【问题描述】:
我有以下 swift 4.1 代码:
let timeduration = NSMutableAttributedString.init(string: "a dynamic string of time");
timeduration.addAttribute(kCTFontAttributeName as NSAttributedStringKey, value: UIFont.systemFont(ofSize: 16), range: NSRange(location: 0, length: timeduration.length));
timeduration.addAttribute(kCTForegroundColorAttributeName as NSAttributedStringKey, value: UIColor(red: 200/255, green: 200/255, blue: 200/255, alpha: 1.0), range: NSRange(location: 0, length: timeduration.length));
timeduration.addAttribute(kCTFontAttributeName as NSAttributedStringKey, value: UIFont.systemFont(ofSize: 50), range: NSRange(location: 0, length: timecount));
timeduration.addAttribute(kCTFontAttributeName as NSAttributedStringKey, value: UIFont.systemFont(ofSize: 25), range: NSRange(location: timecount, length: 2));
我使用的是 Swift 3 并使用 Xcode 的工具迁移到 swift 4.1,但前景色似乎不起作用。 XCode 工具“修复”添加了 kCT 代码。不过,字体名称和大小似乎可以正常工作。
【问题讨论】:
标签: ios iphone swift swift4 ios11