草庐IT

NSMutableAttributedStrings

全部标签

ios - 使用 NSMutableAttributedStrings 快速更改文本颜色

我有一个UITableView,我想在同一行中使用不同的颜色显示每一行的文本。我试过这段代码,试图从Obj-C翻译,但我无法让它工作letobject=self.fetchedResultsController.objectAtIndexPath(indexPath)asNSManagedObjectvarattrString:NSMutableAttributedString=NSMutableAttributedString(string:object.valueForKey("example1")!.description)attrString.addAttribute(NSFo