效果图:
工程图:
此代码需要加入第三方库GifView.
代码:
RootViewController.m
#import "RootViewController.h" //加入头文件 #import "GifView.h" - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. GifView *gifview = [[GifView alloc] initWithFrame:CGRectMake(0, 0, 200, 200) filePath:[[NSBundle mainBundle] pathForResource:@"test.gif" ofType:nil]]; [self.view addSubview:gifview]; }