Sunday, 22 March 2015

Fade In - Fade Out animation in IOS SDK




Fade In - Fade Out animation
Fade In - Fade Out animation



Animations plays a big role in making a smartphone app a nice looking app. IOS apps have different animations that made user's and developer's  fond of IOS platform.

In this post, we are going to share the code for Fade In and Fade out animations. To do these animations we will use UIView's animateWithDuration callback. To fade In a view, we will set the view's alpha to zero at the start and then inside our animation callback set view's alpha to 1.0. On the other hand to Fade out a view we will set its alpha to zero inside animation callback. The face in and fade out animation will work as shown in the image left to your screen. Below are the codes for both animations.




FADE-IN

 optionView.alpha=0.0;
[UIView animateWithDuration:1.0 delay:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^
     {
         optionView.alpha=1.0;
         


     }completion:nil];

Note: optionView is our UIView object.

FADE-OUT

[UIView animateWithDuration:1.0 delay:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^
     {
         optionView.alpha=0.0;
     }completion:^(BOOL finished)
     {
        


     }];

That's it, using the above codes we will get fade in and fade out animations for our views in IOS SDK. 

No comments:
Write comments