To render UILabel as a string, where the first letter of each word is larger, you can do something like this:
@implementation CapitalicTextLabel - (void)drawRect:(CGRect)rect { // Drawing code NSArray* words = [self.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetCharacterSpacing(context, 1); CGContextSetFillColorWithColor(context, [self.textColor CGColor]); CGAffineTransform myTextTransform = CGAffineTransformScale(CGAffineTransformIdentity, 1.f, -1.f ); CGContextSetTextMatrix (context, myTextTransform); CGFloat x = 0; float centeredY = (self.font.pointSize + (self.frame.size.height - self.font.pointSize) / 2) - 2; CGFloat firstLetterSize = self.font.pointSize * 1.4; for (NSString* word in words) { NSString* letter = [[word substringToIndex:1] uppercaseString]; CGContextSelectFont(context, [self.font.fontName cStringUsingEncoding:NSASCIIStringEncoding], firstLetterSize, kCGEncodingMacRoman); CGContextShowTextAtPoint(context, x, centeredY, [letter cStringUsingEncoding:NSASCIIStringEncoding], [letter length]); x = CGContextGetTextPosition(context).x; NSString* restOfWord = [[[word substringFromIndex:1] uppercaseString] stringByAppendingString:@" "]; CGContextSelectFont(context, [self.font.fontName cStringUsingEncoding:NSASCIIStringEncoding], self.font.pointSize, kCGEncodingMacRoman); CGContextShowTextAtPoint(context, x, centeredY, [restOfWord cStringUsingEncoding:NSASCIIStringEncoding], [restOfWord length]); CGPoint v = CGContextGetTextPosition(context); x = CGContextGetTextPosition(context).x; } } @end
This implementation does not handle multiple line breaks or adheres to the TextAlignment parameter, it should be simple enough to add later.
Example:

source share