來自Swift Range的NSRange?問題:當(dāng)我使用使用Range的Swift String時,NSAttributedString接受NSRangelet text = "Long paragraph saying something goes here!"let textRange = text.startIndex..<text.endIndexlet attributedString = NSMutableAttributedString(string: text)text.enumerateSubstringsInRange(textRange, options: NSStringEnumerationOptions.ByWords, { (substring, substringRange, enclosingRange, stop) -> () in
if (substring == "saying") {
attributedString.addAttribute(NSForegroundColorAttributeName, value: NSColor.redColor(), range: substringRange)
}})產(chǎn)生以下錯誤:錯誤:'Range'不能轉(zhuǎn)換為'NSRange'aligolsString.addAttribute(NSForegroundColorAttributeName,value:NSColor.redColor(),range:substringRange)
- 3 回答
- 0 關(guān)注
- 889 瀏覽
添加回答
舉報
0/150
提交
取消