刪除所有屬性

Objective-C

NSMutableAttributedString *mutAttString = @"string goes here";
NSRange range = NSMakeRange(0, mutAttString.length);
[mutAttString setAttributes:@{} range:originalRange];

根據我們使用的 Apple 文件,setAttributes 而不是 addAttribute。

迅速

mutAttString.setAttributes([:], range: NSRange(0..<string.length))