自定义UITableViewCell:添加属性后重置UITextView

时间:2016-01-05 08:28:55

标签: swift uitableview uitextfield tableviewcell

我正在处理通知视图,我希望用户名为粗体,而其余信息不是粗体。目前用户名加粗,但在此过程之后,文本的其余部分变得非常小,我无法解决原因。

let fromUser:PFUser = friendRequests.objectAtIndex(indexPath.row).objectForKey("from") as! PFUser

cell.notificationMessage.text =  fromUser.objectForKey("Name") as! String + " has sent you a friend request."

let boldText: NSMutableAttributedString = NSMutableAttributedString(string: cell.notificationMessage.text)
let stringCount = fromUser.objectForKey("Name") as? String
boldText.addAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(14)], range: NSRange(location: 0, length: (stringCount?.characters.count)!))
cell.notificationMessage.attributedText = boldText

1 个答案:

答案 0 :(得分:0)

你是说lenght stringCount?女巫是用户名的长度,而不是整个文本,尝试更改长度,它应该工作

希望有所帮助