Reputation: 317
I use a UITextField to input text and automatically the UILabel shows that text.
Now, I want to increase the second character's font size, ONLY if user typed 3 characters, if user typed less or more than 3, then all characters should get the default font size.
See attached image.
I want to use NSAttributedText, but I don't know how to increase the second character size only.
Upvotes: 0
Views: 76
Reputation: 9522
Here's what you do:
NSMutableAttributedString *text = [[myTextField attributedText] mutableCopy];
NSDictionary *sizeAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:24.0]};
NSRange secondChar = NSMakeRange(1,1);
[text setAttributes:sizeAttributes range:secondChar];
[myTextField setAttributedText:text];
// might want to release text here, to avoid memory leak
Upvotes: 2