-1

I have one string:"Lorem ipsum dolor sit"

I need to change font size of "ipsum".

Anybody know how can i change the font size of specific word in string.

Larme
  • 24,190
  • 6
  • 51
  • 81
Nimmy
  • 47
  • 1
  • 5

3 Answers3

0

you should use NSAttributedString.

NSMutableAttributedString *myString = [[NSMutableAttributedString alloc] initWithString:@"Lorem ipsum dolor sit"];
[myString addAttribute:NSFontAttributeName value:[UIFont  systemFontOfSize:20.0] range:NSMakeRange(7, 5)];
MD.
  • 1,157
  • 11
  • 18
0

Try this:

 NSMutableAttributedString *string = 
                              [[NSMutableAttributedString alloc]
                                        initWithString: @"Lorem ipsum dolor sit"];



[string addAttribute: NSFontAttributeName
                  value:  [UIFont fontWithName:@"Didot" size:24]
                  range: NSMakeRange(7,5)];
Suraj Sukale
  • 1,778
  • 1
  • 12
  • 19
0
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Lorem ipsum dolor sit"];
[str addAttribute:NSFontAttributeName
              value:[UIFont systemFontOfSize:20.0]
              range:NSMakeRange(7, 5)];
Muthukumar
  • 62
  • 12
  • While working code examples is good, it helps if you can add some more description as to what it is doing and why so that people reading it can understand. – AlBlue Jun 28 '16 at 08:36