[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self initLoadingImageView];
}
- (void)initLoadingImageView
{
NSString *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:@"2.gif" ofType:nil];
NSData *imageData = [NSData dataWithContentsOfFile:filePath];
self.loadingImageView = [[UIImageView alloc]init];
self.loadingImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
self.loadingImageView.backgroundColor = [UIColor blueColor];
//第一種方法使用imageData加載
self.loadingImageView.image = [UIImage sd_animatedGIFWithData:imageData];
//第二種方法使用圖片名字加載
//self.loadingImageView.image = [UIImage sd_animatedGIFNamed:@"2"];
[self.view addSubview:self.loadingImageView];
[self.view bringSubviewToFront:self.loadingImageView];