这里记录下我实现在iOS端上进行Gif动画播放的代码。
调用代码:
@interface ViewController ()
@property (nonatomic , strong) QGifView *gifView;
@end
@implementation ViewController
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[_gifView startGif];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *fileUrl = [[NSBundle mainBundle] URLForResource:@"snow" withExtension:@"gif"];
_gifView = [[QGifView alloc] initWithCenter:CGPointMake(self.view.bounds.size.width / 2, 13) fileURL:fileUrl];
_gifView.backgroundColor = [UIColor clearColor];
_gifView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:_gifView];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(0, 0, 100, 60);
btn.center = CGPointMake(100, self.view.bounds.size.height - 50);
btn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutore