Increasing the font size of first letter in UILabel.text

ios, uilabel

Solution

To get, for example, this:

Say this:

NSString* s2 = @"Fourscore and seven years ago, our fathers brought forth "
    @"upon this continent a new nation, conceived in liberty and dedicated "
    @"to the proposition that all men are created equal.";
NSMutableAttributedString* content2 =
    [[NSMutableAttributedString alloc]
     initWithString:s2
     attributes:
         @{
           NSFontAttributeName:
               [UIFont fontWithName:@"HoeflerText-Black" size:16]
         }];
[content2 setAttributes:
    @{
      NSFontAttributeName:[UIFont fontWithName:@"HoeflerText-Black" size:24]
     } range:NSMakeRange(0,1)];
[content2 addAttributes:
    @{
      NSKernAttributeName:@-4
     } range:NSMakeRange(0,1)];

NSMutableParagraphStyle* para2 = [NSMutableParagraphStyle new];
para2.headIndent = 10;
para2.firstLineHeadIndent = 10;
para2.tailIndent = -10;
para2.lineBreakMode = NSLineBreakByWordWrapping;
para2.alignment = NSTextAlignmentJustified;
para2.lineHeightMultiple = 1.2;
para2.hyphenationFactor = 1.0;
[content2 addAttribute:NSParagraphStyleAttributeName
                 value:para2 range:NSMakeRange(0,1)];

Then assign `content2` to a label's `attributedText`.

Problem

I would like the first letter of the UILabel to have a different font size from others, a few font size larger. Need some guidance on how to do it. The label has a lot of words. This is what I have tried: ``` NSArray * words = [Label.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; NSString *firstLetter = [[words objectAtIndex:0] substringToIndex:1]; ``` But got stuck in increasing the size of the NSString. Is there a better way? I am welcome to suggestions and guidance.. Thanks.. EDIT: ``` [Label setFont:[UIFont fontWithName:@"Arial" size:12.f]]; NSArray * words = [Label.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; UIFont *fontFirst=[UIFont fontWithName:@"Arial" size:15.f]; NSDictionary *attrsDictFirst=[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; NSAttributedString *finalString=[[NSAttributedString alloc] initWithString:[[words objectAtIndex:0] substringToIndex:1] attributes:attrsDictFirst]; ```

Original source