Jes*_*ica 3 uibutton ios nsmutableattributedstring swift
我有一个UIButton. 我试图让buttons title2 行,第二行应该比第一行小。这是我的代码:
var myMutable = NSMutableAttributedString(string: "someText\n\(someString)", attributes: [NSFontAttributeName:UIFont.systemFontOfSize(17)])
myMutable.addAttribute(NSFontAttributeName, value: UIFont.systemFontOfSize(14), range: NSRange(location: count("someText\n") - 1, length: count(someString) - 1))
self.myButton.setAttributedTitle(myMutable, forState: .Normal)
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当这段代码被执行时,什么也没有发生。我做错了什么,我该如何解决?
更新
我只是尝试为它添加颜色,这部分起作用了。所以唯一的事情是,它没有 2 行。
| 归档时间: |
|
| 查看次数: |
846 次 |
| 最近记录: |