Reputation: 34818
Can someone summarise the key pieces of objective-c code that would assist in solving this.
Objective - Autoresize a UITableView after a user changes the font size. Therefore if the user increases or descreases font both the (a) uiLabel heights should change to ensure they nicely include text, and (b) uiTableViewCell heights should also adjust.
Assumption is that:
So I assume the challenge / questions I have would include (and hopefully be answered by some sample code that someone can post)
Hope this makes sense.
thanks
Upvotes: 0
Views: 1881
Reputation: 2421
To get the UILabel's height to match your target font, you use the sizeWithFont
function of NSString
.
NSString *myText = @"Go Hokies";
UIFont *myFont = [UIFont boldSystemFontOfSize:15];
CGFloat lineHeight = [myText sizeWithFont:myFont].height;
The problem you may run into is if the text doesn't fit horizontally in the bounds you've defined. If you want the font to downsize accordingly, turn on the adjustment flag and set a min like this.
myUILabel.minimumFontSize = 10;
myUILabel.adjustsFontSizeToFitWidth = YES;
Upvotes: 2
Reputation: 7819
Upvotes: 2