core-text

NSAttributedString superscript styling

假装没事ソ 提交于 2019-11-26 09:34:53
问题 I want to superscript all the instances of ® character in a block of text (legal disclaimer, naturally ;)) and the default way NSAttributedString is not very good. If I just let the character be and only use unmodified NSString , it is rendered the same size as a capital letter and is placed approximately at the baseline. If I add the superscript attribute to NSAttributedString as follows: [attrStr setAttributes:@{(NSString *)kCTSuperscriptAttributeName : @1} range:NSMakeRange(locationOfReg,

Convert HTML to NSAttributedString in iOS

点点圈 提交于 2019-11-26 00:35:43
问题 I am using a instance of UIWebView to process some text and color it correctly, it gives the result as HTML but rather than displaying it in the UIWebView I want to display it using Core Text with a NSAttributedString . I am able to create and draw the NSAttributedString but I am unsure how I can convert and map the HTML into the attributed string. I understand that under Mac OS X NSAttributedString has a initWithHTML: method but this was a Mac only addition and is not available for iOS. I