How to fade in/out multiple images before image faded

Discussion in 'iOS Programming' started by teeming, Dec 26, 2010.

  1. teeming macrumors newbie

    Dec 26, 2010
    Hi all,

    I plan to do multiple images fade in/out using UIImageView just like Flicker iphone app.

    Here are the steps:
    1. Load pic1.
    2. pic1 move from left to right.
    3. pic1 will slowly turn to become transparent while still moving.
    4. Same time pic2 is moving from right to left.

    I am managed to have the pic1 slowly fading out after it stop moving and pic2 move in at the same time. However what i want is to have the pic1 slowly fading out while it is still moving.

    Can anybody help me to look at my code below: Thanks.

    - (void)viewDidLoad {
    [super viewDidLoad];

    CGPoint newLeftCenter = CGPointMake(180, 240);
    [UIView beginAnimations:mad:"move1" context:NULL];
    [UIView setAnimationDuration:6.0f];

    [UIView setAnimationCurve:UIViewAnimationTransitionFlipFromRight];

    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:mad:selector(movingStop:finished:context:)]; = newLeftCenter;
    [UIView commitAnimations];

    - (void)movingStop:(NSString*)animationID finished:(BOOL)finished context:(void *)context {

    if ( [animationID isEqualToString:mad:"move1"] ) {

    CGPoint newLeftCenter = CGPointMake(200, 260);
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationCurve:UIViewAnimationTransitionFlipFromLeft];

    [UIView setAnimationDuration:3.0];

    pic2.alpha = 1.0; = newLeftCenter;
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:selector(movingStop:finished:context:)];

    [UIView commitAnimations];

  2. nickculbertson macrumors regular


    Nov 19, 2010
    Nashville, TN
    Here is how I fade alpha in viewDidLoad.

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelay:1.0];
    [UIView setAnimationDuration:1.0];
    pic1.alpha = 0.0;
    [UIView commitAnimations];

Share This Page