iOS开发中在UIWebView中添加Gif动态图

  开发是一件很有趣的事,偶尔在程序中添加一些小东西,会给你的应用增色不少。比如,当你的某些功能暂时还不准备上线时,可以先一个放展示Gif动态图的UIWebView上去,既可以告诉用户APP以后会有的功能,也会使你的APP手动可爱,打动一大波妹子。

   下面给出了一种添加Gif动态图的方法:

- (void)viewDidLoad {

    [super viewDidLoad];

    [self initWithPictureAnimation];

}

 

-(void)initWithPictureAnimation{

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 150, self.view.bounds.size.width, 400)];

 

    webView.backgroundColor = [UIColor whiteColor];

    

    NSData *gif = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myWallet" ofType:@"gif"]];

    

    webView.userInteractionEnabled = NO;

    

    [webView loadData:gif MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];

    

    [self.view addSubview:webView];

}

 

posted on 2015-08-10 12:05  乱七八糟21号  阅读(1281)  评论(0编辑  收藏  举报

导航