Animations program:
AppDelegate.h:----
#import <UIKit/UIKit.h>
@class Animations2ViewController;
@interface Animations2AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
Animations2ViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet Animations2ViewController *viewController;
@end
AppDelegate.m:----
#import "Animations2AppDelegate.h"
#import "Animations2ViewController.h"
@implementation Animations2AppDelegate
@synthesize window;
@synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
Animations2ViewController.h:----
#import <UIKit/UIKit.h>
@interface Animations2ViewController : UIViewController<UIAccelerometerDelegate> {
IBOutlet UIImageView *imgView;
IBOutlet UIButton *btn1;
IBOutlet UIButton *btn2;
}
-(IBAction)startAnimating;
-(IBAction)stopAnimating;
@end
Animations2ViewController.m:----
#import "Animations2ViewController.h"
@implementation Animations2ViewController
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
NSLog(@"device moved");
}
-(IBAction)startAnimating{
[imgView startAnimating];
}
-(IBAction)stopAnimating{
[UIView beginAnimations:@"animation1" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:10];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:btn2 cache:YES];
btn1.frame =CGRectMake(100, 300, 60, 40);
[UIView commitAnimations];
}
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *img1= [UIImage imageNamed:@"1.jpg"];
UIImage *img2= [UIImage imageNamed:@"2-1.jpg"];
UIImage *img3= [UIImage imageNamed:@"2.jpg"];
UIImage *img4= [UIImage imageNamed:@"3.jpg"];
NSArray *arrImages =[[NSArray alloc]initWithObjects:img1,img2,img3,img4,nil];
imgView.animationImages =arrImages;
imgView.animationDuration =10;
}
- (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 {
}
- (void)dealloc {
[super dealloc];
}
@end
0 comments:
Post a Comment