I would try setting the labels property
@property(nonatomic) BOOL adjustsFontSizeToFitWidth
to YES and see if that fixes the problem. Let me know if not. I had a problem in a different situation, but i ended up using some code to change the size manually.
Here is the code i used to change the font size manually then. Im not sure what your problem is but this ended up being a good fix for my problem. Just call this method when you set your labels text and then set the font size yourself.
- (CGFloat)requiredFontSizeForLabel:(UILabel *)label
{
if (!label) {
return kFontSize;
}
CGFloat originalFontSize = kFontSize;
UIFont* font = label.font;
CGFloat fontSize = originalFontSize;
BOOL found = NO;
do
{
if( font.pointSize != fontSize )
{
font = [font fontWithSize: fontSize];
}
if([self wouldThisFont:font workForThisLabel:label])
{
found = YES;
break;
}
fontSize -= 0.5;
if( fontSize < (label.minimumScaleFactor * label.font.pointSize))
{
break;
}
} while( TRUE );
return( fontSize );
}
- (BOOL) wouldThisFont:(UIFont *)testFont workForThisLabel:(UILabel *)testLabel {
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:testFont, NSFontAttributeName, nil];
NSAttributedString *as = [[NSAttributedString alloc] initWithString:testLabel.text attributes:attributes];
CGRect bounds = [as boundingRectWithSize:CGSizeMake(CGRectGetWidth(testLabel.frame), CGFLOAT_MAX) options:(NSStringDrawingUsesLineFragmentOrigin) context:nil];
BOOL itWorks = [self doesThisSize:bounds.size fitInThisSize:testLabel.bounds.size];
return itWorks;
}
- (BOOL)doesThisSize:(CGSize)aa fitInThisSize:(CGSize)bb
{
if ( aa.width > bb.width ) return NO;
if ( aa.height > bb.height ) return NO;
return YES;
}