Yeah, there\'s this cool myLabel.adjustsFontSizeToFitWidth = YES;
property. But as soon as the label has two lines or more, it won\'t resize the text to anythin
Niels Castle code work find.
Here is the same idea with a different implementation.
My solution is more precise but also much more CPU intensive.
Add this function to a class who inherit UILabel.
-(void)fitCurrentFrame{
CGSize iHave = self.frame.size;
BOOL isContained = NO;
do{
CGSize iWant = [self.text sizeWithFont:self.font];
if(iWant.width > iHave.width || iWant.height > iHave.height){
self.font = [UIFont fontWithName:self.font.fontName size:self.font.pointSize - 0.1];
isContained = NO;
}else{
isContained = YES;
}
}while (isContained == NO);
}