Reputation: 689
How to set minimumfont size or minimumscalfactor(ios7) with the attributed string.
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = self.lineBreakMode;
paragraphStyle.alignment = self.textAlignment;
NSDictionary *dictionary = @{ NSFontAttributeName: self.font,
NSParagraphStyleAttributeName: paragraphStyle,
NSForegroundColorAttributeName:self.textColor};
[self.formattedText drawAtPoint:vLineRect.origin withAttributes:dictionary];
Please suggest how can i set minimumfont size in attributed string?
Upvotes: 0
Views: 2000
Reputation: 8247
To replace minimumFontSize
you need to use minimumScaleFactor
with iOS 7 like this :
[_myLabel setMinimumScaleFactor:10.0/FONT]];
10.0 will be the minimum size.
And replace FONT by your custom font with the size ( [UIFont fontWithName:@"nameOfFont" size:15.0f]
, with the name of your font and the size you want ).
So with iOS 6 it would be the same as :
[_myLabel setMinimumFontSize:10.0];
Apple Documentation here.
You can add a test to use minimumFontSize
with iOS 6 and minimumScaleFactor
with iOS 7 :
if ([_myLabel respondsToSelector:@selector(setMinimumScaleFactor:)])
[_myLabel setMinimumScaleFactor:10.0/FONT]];
else
[_myLabel setMinimumFontSize:10.0];
Upvotes: 3