views:

197

answers:

1

I want a UILabel to swell slightly when selected like in some game menu screens. To get smooth resizing I presume I should put some change to the label's properties in an animation block.

The obvious thing to try is to change the label.font.pointSize property but that's readonly.

Scaling the label's .transform property with CGAffineTransformationMakeScale() makes the text blurry.

Is there some other way to do this?

A: 

You can't change the point size of the font, but you can replace the UILabel's font with a new UIFont that uses the new point size you desire.

label.font = [UIFont fontWithName:@"Arial-BoldMT" size:12.0];
// ... some time later
label.font = [UIFont fontWithName:@"Arial-BoldMT" size:14.0];

You'll probably also want to modify the UILabel's frame to accommodate the new point size, especially if you're increasing the point size. Otherwise, your label will get cropped.

Jay
Does that smoothly animate?
willc2
Not on its own. Scale the UILabel using a transformation like you already mentioned and once the animation is complete, assign the larger UIFont to the UILabel. This should give you the same effect you see when you zoom in and out in mobile Safari. The text is slightly blurry during the pinch/zoom, but once the gesture is complete, the text is rendered using a different font size that matches the current zoom level.
Jay