【发布时间】:2017-05-19 06:22:55
【问题描述】:
我已经为此苦苦挣扎了一段时间。但是我在搞乱远程通知,老实说,我似乎无法找到一种方法来加粗通知中的第一行。这是我的代码
let boldUser = backendless!.userService.currentUser.name!
let string: NSString = "\(boldUser) \nMessage: \(message)" as NSString
let attributedString = NSMutableAttributedString(string: string as String, attributes: [NSFontAttributeName:UIFont.systemFont(ofSize: 15.0)])
let boldFontAttribute = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: 15.0)]
// Part of string to be bold
attributedString.addAttributes(boldFontAttribute, range: string.range(of: "\(boldUser)" as String))
publishOptions.assignHeaders(["ios-alert" : "\(string)", "ios-badge" : "\(counter)", "ios-sound" : "message_tone_3.mp3"])
我不明白为什么这不起作用。据我所知,我做的一切都是正确的,但是当我测试时,没有一个通知是粗体的。我正在尝试将第一行加粗。
【问题讨论】: