我想在导航栏标题中更改字符间距.我想使用以下代码. 
  
  
 
let attributedString = NSMutableAttributedString(string: "New Title")
        attributedString.addAttribute(NSKernAttributeName,value:   CGFloat(1.4),range: NSRange(location: 0,length: 9))
        self.navigationItem.title = attributedString 
 这会产生以下错误:
无法将类型为“NSMutableAttributedString”的值分配给“string?”类型的值
有人可以帮我这个或建议一种不同的方式来改变swift中导航栏标题中的字符间距吗?
解决方法
 您无法直接设置属性字符串. 
  
 
        你可以通过替换titleView来做一个技巧
let titleLabel = UILabel() let colour = UIColor.redColor() let attributes: [Nsstring : AnyObject] = [NSFontAttributeName: UIFont.systemFontOfSize(12),NSForegroundColorAttributeName: colour,NSKernAttributeName : 5.0] titleLabel.attributedText = NSAttributedString(string: "My String",attributes: attributes) titleLabel.sizetoFit() self.navigationItem.titleView = titleLabel