views:

340

answers:

2

Hello, Im currently working on an iPhone project. I want to enlarge dynamically an UILabel in Objective-C like this: alt text

How is this possible? I thought I have to do it with CoreAnimation, but I didn't worked. Here is the code I tried:

    UILabel * fooL = //[…]
    fooL.frame = CGRectMake(fooL.frame.origin.x, fooL.frame.origin.y, fooL.frame.size.width, fooL.frame.size.height);   
    fooL.font = [UIFont fontWithName:@"Helvetica" size:80];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];
    fooL.font = [UIFont fontWithName:@"Helvetica" size:144]; //bigger size
    fooL.frame = CGRectMake(20 , 44, 728, 167); //bigger frame
    [UIView commitAnimations];

The problem with this code is that it doesn't change the fontsize dynamically.

A: 

Try this method:

  • (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache

Parameters: transition A transition to apply to view. Possible values are described in UIViewAnimationTransition.

view The view to apply the transition to.

cache If YES, the before and after images of view are rendered once and used to create the frames in the animation. Caching can improve performance but if you set this parameter to YES, you must not update the view or its subviews during the transition. Updating the view and its subviews may interfere with the caching behaviors and cause the view contents to be rendered incorrectly (or in the wrong location) during the animation. You must wait until the transition ends to update the view.

If NO, the view and its contents must be updated for each frame of the transition animation, which may noticeably affect the frame rate.

Discussion If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:

Begin an animation block. Set the transition on the container view. Remove the subview from the container view. Add the new subview to the container view. Commit the animation block.

jekmac
A: 

I got it, look at this (it is a sample project for the iPhone): link text

Flocked