开发者

UILabel text scaling, Programmatically?

I want to change my UILabel text or UILabel itself's size by using UISlider, I know it's something we don't do it for an normal application. But basically I am trying new and different things to explore Objecti开发者_开发技巧ve -C language and iOS platform.

So far I am able to change colour of a font by UISlider, Which looks really great, So thought of changing it's size too by UISlider. Below I am posting pictures to clarify my thoughts visually!

From ----->

UILabel text scaling, Programmatically?

To ------->

UILabel text scaling, Programmatically?

While making those images I realised I might have to change size of UILable and Size of font too. Am I right? Is this possible?


textLabel.font = [UIFont boldSystemFontOfSize:slider.value];    
CGSize newSize = [textLabel.text sizeWithFont:textLabel.font];    

This should make it
an alternative is to set the fram of the label above the complete size above the textField and set textAlignement = center


its quite simple actually

According to slider change value dynamically increase height and width of your label..


There can be many ways you can handle this, one way would be to just change the font size with slider and when you change the font calculate the frame size with sizeWithFont: instance method of NSString.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜