views:

31

answers:

1

In some of the applications, I have seen that we have an option to increase or decrease the fontSize of the text inside the label. But when we adjust it, the label automatically increases its height to contain it. How do we get the height of the label everytime we increase or decrease the fontsize?

And in some cases like news applications when it loads, there will be text only. But suddenly the image comes and the text readjusts itself to contain it. How does it do it by itself?

Someone plz help me...

A: 
CGSize textSize = [@"foobar" sizeWithFont:[UIFont boldSystemFontOfSize:18]];

Checkout NSString UIKit Additions. It has got a couple of these methods that let you ask a string how big it would be when rendered with a given font. With that information, you should be able to adjust things however you need with a little math.

Also, in some cases, it may be a web view. If this is the case, HTML/CSS sort of flows stuff around automatically in order to keep things tidy.

Squeegy