将 2 行属性字符串添加到 UIButton 的标题不起作用

Add 2 lines of attributed string to title of UIButton not working

我有一个UIButton。我试图让 buttons title 有 2 行,第二行应该比第一行小。这是我的代码:

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)

出于某种原因,执行此代码时没有任何反应。我做错了什么,我该如何解决?

更新

我只是尝试给它添加颜色,这部分工作。所以唯一的问题是,它没有 2 行。

试试这个:

button.titleLabel?.numberOfLines = 0;