How is the text adjusting inside the label when we increase the fontSize?

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...

Answers


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.


Need Your Help

AngularJS + ion-list ng-repeat not Populating List

javascript php angularjs ionic-framework

I am trying to populate an ion-list with ng-repeat from the database in Intel XDK using AngularJS and PHP.

How to obtain a CGImageRef from the content of an UIView?

iphone cocoa-touch uikit core-graphics quartz-2d

I have an UIView where I was drawing some stuff inside -drawRect:. Now I need a CGImageRef from this graphics context or bitmap of the UIView. Is there an easy way to get that?