How to fade in/out multiple images before image faded

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

  1. teeming macrumors newbie

    Joined:
    Dec 26, 2010
    #1
    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:)];

    pic1.center = 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;

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

    [UIView commitAnimations];

    }
     
  2. nickculbertson macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #2
    Here is how I fade alpha in viewDidLoad.

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

Share This Page