弹出动画
? ? //
// ?TestBedViewControler_006.m
// ?UIViewAnimationsTest
//
// ?Created by mir on 11-4-1.
// ?Copyright 2011 __MyCompanyName__. All rights reserved.
//
?
#import "TestBedViewControler_006.h"
#import "UIView-ModalAnimationHelper.h"
?
?
@implementation TestBedViewControler_006
?
/*
?// The designated initializer. ?Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
? ? if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
? ? ? ? // Custom initialization
? ? }
? ? return self;
}
*/
?
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
?
-(void) animate:(id) sender{
//hide the bar button and show the view
self.navigationItem.rightBarButtonItem=nil;
[self.view viewWithTag:101].alpha=1.0f;
//Bounce to 1155 of the normal size
[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];//标记动作块开始
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; //定义动画加速和减速的方式
[UIView setAnimationDuration:0.4f];//设置动画时长
[self.view viewWithTag:101].transform=CGAffineTransformMakeScale(1.15f, 1.15f);
[UIView commitModalAnimations];//结束动画块
//Return back to 100%
[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3f];
[self.view viewWithTag:101].transform=CGAffineTransformMakeScale(1.0f, 1.0f);
[UIView commitModalAnimations];
//Pause for a second and appreciate the presentation
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
//Slowly zoom back down and hide the view
[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0f];
[self.view viewWithTag:101].transform=CGAffineTransformMakeScale(0.01f, 0.01f);
[UIView commitModalAnimations];
[self.view viewWithTag:101].alpha=0.0f;
//Restore the bar button
self.navigationItem.rightBarButtonItem=BARBUTTON(@"Bounce",@selector(animate:));
}
?
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
? ? [super viewDidLoad];
self.navigationItem.rightBarButtonItem=BARBUTTON(@"Bounce",@selector(animate:));
direction = 0;
UIImageView *view1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]];
view1.tag=101;
[self.view addSubview:view1];
[view1 release];
[self.view viewWithTag:101].transform = CGAffineTransformMakeScale(0.01f, 0.01f);//用于缩放图像 最大为1
[self.view viewWithTag:101].alpha = 0.0f;
}
?
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
? ? // Return YES for supported orientations
? ? return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
?
- (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 {
? ? [super viewDidUnload];
? ? // Release any retained subviews of the main view.
? ? // e.g. self.myOutlet = nil;
}
?
?
- (void)dealloc {
? ? [super dealloc];
}
?
?
@end