- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
iv.image = [UIImage imageNamed:@"yeah"];
[self.view addSubview:iv];
[iv release];
UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(100, 100, 100, 30);
[btn addTarget:self action:@selector(btnPress:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
-(void)btnPress:(id)sender
{
CALayer * layer = [[CALayer alloc] init];
layer.frame = CGRectMake(0, 0, 320, 460);
layer.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f].CGColor;
[self.view.layer addSublayer:layer];
[layer release];
UIImageView * animateImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"scene.jpg"]];
animateImageView.frame = CGRectMake(0, -460, 320, 460);
[self.view addSubview:animateImageView];
[animateImageView release];
[UIView animateWithDuration:0.6f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^(void){
animateImageView.frame = CGRectMake(0, 0, 320, 460);
} completion:^(BOOL finished){
[UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(void){
animateImageView.frame = CGRectMake(0, -60, 320, 460); //弹起
} completion:^(BOOL finished){
[UIView animateWithDuration:0.15f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^(void){
animateImageView.frame = CGRectMake(0, 0, 320, 460);
} completion:^(BOOL finished){
[UIView animateWithDuration:0.05f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(void){
animateImageView.frame = CGRectMake(0, -20, 320, 460); //弹起
} completion:^(BOOL finished){
[UIView animateWithDuration:0.1f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^(void){
animateImageView.frame = CGRectMake(0, 0, 320, 460);
} completion:^(BOOL finished){
[UIView animateWithDuration:0.1f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(void){
animateImageView.frame = CGRectMake(0, -4, 320, 460); //弹起
} completion:^(BOOL finished){
[UIView animateWithDuration:0.1f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^(void){
animateImageView.frame = CGRectMake(0, 0, 320, 460);
} completion:^(BOOL finished){
[UIView animateWithDuration:0.3f delay:0.5f options:UIViewAnimationOptionCurveEaseIn animations:^(void){
animateImageView.frame = CGRectMake(0, -460, 320, 460);
} completion:^(BOOL finished){
[animateImageView removeFromSuperview];
[layer removeFromSuperlayer];
}];
}];
}];
}];
}];
}];
}];
}];
}