I\'ve a issue regarding showing registered symbol as superscript. I\'ve used unicode value \\u00AE, but it shows in same line. I\'d like to have it a bit top of remaining texts.
From iOS6 on, you can actually use a NSAttributedString with a UILabel.
To set superscript for the registered trademark symbol, you can use the following category:
#import
#import "UILabel+ SetSuperScriptForRegisteredTrademarkSymbol.h"
@implementation UILabel (SetSuperScriptForRegisteredTrademarkSymbol)
- (void) setSuperScriptForRegisteredTrademarkSymbol {
NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:self.text];
NSUInteger count = 0, length = [mutableAttributedString length];
NSRange range = NSMakeRange(0, length);
while(range.location != NSNotFound)
{
range = [[mutableAttributedString string] rangeOfString:@"®" options:0 range:range];
if(range.location != NSNotFound) {
[mutableAttributedString addAttribute:(NSString*)kCTSuperscriptAttributeName value:@"1" range:range];
range = NSMakeRange(range.location + range.length, length - (range.location + range.length));
count++;
}
}
self.attributedText = mutableAttributedString;
}
@end