iPhone: UIImageView Fades in - Howto?

Ian Vink picture Ian Vink · Apr 12, 2011 · Viewed 21.7k times · Source

I have an UIImageView that I want to fade in.

Is there a way to enable that on an underlying UIViewController?

I have translated the simplest answer, though they all work, C# .NET for the MonoTouch users:

public override void ViewDidAppear (bool animated)
{
    base.ViewDidAppear (animated);
    UIView.BeginAnimations ("fade in");
    UIView.SetAnimationDuration (1);
    imageView.Alpha = 1;
    UIView.CommitAnimations ();
}

Answer

visakh7 picture visakh7 · Apr 12, 2011

Initially set the alpha of your imageview as 0 as imageView.alpha = 0;

- (void)fadeInImage 
{
[UIView beginAnimations:@"fade in" context:nil];
    [UIView setAnimationDuration:1.0];
    imageView.alpha = 1.0;
    [UIView commitAnimations];

}