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 ();
}
I would use UIView's +transitionWithView:duration:options:animations:completion: It is very efficient and powerful.
You can use this code:
Fade In Animation:
Fade Out Animation:
self.yourComponent
can be aUIView
,UIImageView
,UIButton
or any other component.Initially set the alpha of your imageview as 0 as
imageView.alpha = 0;
Change the animation duration to what ever length you want.
Use below in your
UIViewController
Swift version