How to separate attributes from a NSAttributed String and apply these attributes on other string?
问题 eg. Like we have a NSAttributed string and we need to separate string and attributes, then use these attributes on other string of same length. 回答1: An NSAttributedString may have different attributes for different ranges of the string. To extract these attributes, you can use the enumerateAttributesInRange method. We prepare an array of tuples to hold the results: var extractedAttributes = [(attributes: [String:AnyObject], range: NSRange)]() Each tuple will hold the attributes for a specific