嗨,我正在尝试在
Swift3中使用addAttribute.
我想要只设置粗体IDNAME.
这就是我想要的.
let boldUsername = NSMutableAttributedString(string: "IDNAME hi nice 2 meet you :D #HELLOW") // boldUsername.addAttribute(NSFontAttributeName,value: UIFont(name: "SFUIText-Bold",size: 14)!,range: (boldUsername.string as Nsstring).range(of: " ")) boldUsername.addAttribute(NSFontAttributeName,range: NSRange(location: 0,length: 5))
我如何获得IDNAME的索引,即每次都不同?
– >有没有办法分割空间并获得索引?