我正在尝试在我的后退按钮上设置富文本字符串。
这是我第一次尝试使用富文本字符串。
以下是代码:
self.navigationItem.hidesBackButton = true
let barButtonBackStr = "< Back"
var attributedBarButtonBackStr = NSMutableAttributedString(string: barButtonBackStr as String)
attributedBarButtonBackStr.addAttribute(NSFontAttributeName,
value: UIFont(
name: "AmericanTypewriter-Bold",
size: 18.0)!,
range: NSRange(
location:0,
length:1))
let newBackButton = UIBarButtonItem(title: attributedBarButtonBackStr, style: UIBarButtonItemStyle.Plain, target: self, action: "barButtonBack:")
self.navigationItem.leftBarButtonItem = newBackButton
这会在Xcode中导致以下错误。
无法使用类型为'(title: NSMutableAttributedString, style: UIBarButtonItemStyle, target: CombatOutcomeViewController, action: String)'的参数列表调用类型为'UIBarButtonItem'的初始化器
有人知道如何解决吗?谢谢。