Image_FadeIn_FadeOutViewController.h
#import <UIKit/UIKit.h>
@interface Image_FadeIn_FadeOutViewController : UIViewController {
IBOutlet UIImageView *image;
IBOutlet UIButton *button;
}
-(IBAction)hideImage;
@end
Image_FadeIn_FadeOutViewController.m
#import "Image_FadeIn_FadeOutViewController.h"
@implementation Image_FadeIn_FadeOutViewController
-(IBAction)hideImage{
CGContextRef imageContext = UIGraphicsGetCurrentContext();
if (image.alpha == 1) {
[UIView beginAnimations:nil context:imageContext];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:4];
[UIView setAnimationDelegate:self];
image.alpha = 0.0;
[button setTitle:@"Show Cat" forState:UIControlStateNormal];
}else if (image.alpha == 0) {
[UIView beginAnimations:nil context:imageContext];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:4];
[UIView setAnimationDelegate:self];
image.alpha = 1;
[button setTitle:@"Hide Cat" forState:UIControlStateNormal];
}
[UIView commitAnimations];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
詳解 Objective-C 2.0 改訂版: 荻原 剛志 | iPhoneプログラミングUIKit詳解リファレンス: 所 友太, 京セラコミュニケーションシステム株式会社 | iPhone SDK アプリケーション開発ガイド: Jonathan Zdziarski, 近藤 誠 (監訳), 武舎 広幸, 武舎 るみ |
0 コメント:
コメントを投稿