Reputation: 1434
Can I have Kerning for custom fonts in ios for UILable and UIButton?
Below method is not working. Kerning works for system font but not for Custom fonts. Can Somebody help in solving issue?
NSMutableAttributedString *attributedString =
[[NSMutableAttributedString alloc] initWithString:text attributes:
@{
NSFontAttributeName : [UIFont fontWithName:@"BebasNeue Bold" size:25],
NSForegroundColorAttributeName : [UIColor redColor]
}];
[attributedString addAttribute:NSKernAttributeName
value:[NSNumber numberWithFloat:kerning]
range:NSMakeRange(0, [text length])];
[self setAttributedText:attributedString];
Upvotes: 2
Views: 528
Reputation: 1565
You can try this. It might help.
NSMutableAttributedString *attributedString;
attributedString = [[NSMutableAttributedString alloc] initWithString:@"Please test this text"];
[attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(10, 5)];
[self.label setAttributedText:attributedString];
for more solution please check the following link
How to set kerning in iPhone UILabel
I hope this helps .
Upvotes: 4