Xcode版本4.5.1
1. 開啓一個專案
2. 加入動畫連續的圖檔,本例共六張PNG圖
3. 在mainViewController.m加入程式碼
#import "mainViewController.h"
@interface mainViewController ()
@end
@implementation mainViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSArray *hopAnimation;
hopAnimation=[[NSArray alloc] initWithObjects: //Set array below
[UIImage imageNamed:@"1001.png"],
[UIImage imageNamed:@"1002.png"],
[UIImage imageNamed:@"1003.png"],
[UIImage imageNamed:@"1004.png"],
[UIImage imageNamed:@"1005.png"],
[UIImage imageNamed:@"1006.png"],
nil
];
UIImageView *a2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100,200)];
a2.animationImages=hopAnimation;
a2.animationDuration=3;
//a2.startAnimating = YES;
[a2 startAnimating];
[self.view addSubview:a2];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
4.結果截圖錄影








沒有留言:
張貼留言