Search code examples
xcode6fadeduration

I want my image in xCode to fade in


I want my image to fade IN, not out. With this code, it's backwards. Any help?

[UIView animateWithDuration:3.0 animations:^{ self.circleOne.alpha = 0.0;

    }];

Solution

  • If your circleOne has alpha 0(invisible) all you need to do is set the alpha to 1:

    [UIView animateWithDuration:3.0 animations:^{
     self.circleOne.alpha = 1.0;
    }];
    

    Edit:

    If you want to make a animation before it appears on screen, you can set the alpha to 0 before adding the circleOne the it's parentview.

    Assuming that circleOne is an UIImageView it would be like this:

    circleOne = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"imageName,jpg"]];
    circleOne.alpha = 0.0;
    [parentView addSubview: circleOne];
    //run the animation explained before