iPhone Programming - Fade In & Out a UIImageView

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,754
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Feb 9, 2011

A tutorial teaching you how to animate a UIImageView so it fades in and out nicely with the click of a button.

Main Code Used:
-(IBAction)hideImage {
CGContextRef *imageContext = UIGraphicsGetCurrentContext();
if (image.alpha == 1) {
[UIView beginAnimations:nil context:imageContext];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:3];
[UIView setAnimationDelegate:self];
image.alpha = 0.0;
[button setText:@"Show Image" forState:UIControlStateNormal];
} else if (image.alpha == 0.0) {
[UIView beginAnimations:nil context:imageContext];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:3];
[UIView setAnimationDelegate:self];
image.alpha = 1;
[button setText:@"Hide Image" forState:UIControlStateNormal];
}

[UIView commitAnimations];
}

Next Video: http://www.youtube.com/watch?v=a_MPhB4Xnps
Previous Video: http://www.youtube.com/watch?v=H1wOlmwN94o

Link: http://developer.apple.com/devcenter/ios/index.action
Website: http://failcake.webs.com/
Twitter: http://twitter.com/failcakeapps
Channel: http://youtube.com/milmersxcode

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (MilmersXcode)

  • Man continue with the great tutorials, it helps me a lot! But I would Still love if you could put the code in the description. Thanks!

  • @LockerzSwagbucks Thanks alot. The next Tutorial in this series is out so go and watch it. Link in the description. My Next series will be on UITableViews so stay tuned for that as well.

  • @LockerzSwagbucks I won't put all the code in the descriptions but the main bits of code that will be used in the video. Hope this helps :D

see all

All Comments (4)

Sign In or Sign Up now to post a comment!
Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more