iOS中如何显示gif图-创新互联

这篇文章主要介绍了iOS中如何显示gif图,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

10年积累的网站建设、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先建设网站后付款的网站建设流程,更有灌南免费网站建设让你可以放心的选择与我们合作。

显示本地gif图

SDWebImage和YYImage的显示本地图片代码。

//load loacle gif image- (void)loadLocaleGifImage{ //sdwebimage [self labelFactoryWithFrame:CGRectMake(0, 80, kScreenWidth, 20) title:@"SDWebImage"]; NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"gif"]; NSData *gifData = [NSData dataWithContentsOfFile:path]; UIImageView *sdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 100, kScreenWidth, kScreenHeight/3)]; sdImageView.image = [UIImage sd_animatedGIFWithData:gifData]; [self.view addSubview:sdImageView]; //yyImage show gif image [self labelFactoryWithFrame:CGRectMake(0, kScreenHeight/2 - 20, kScreenWidth, 20) title:@"yyImage"]; YYImage *yyimage = [YYImage imageNamed:@"test.gif"]; YYAnimatedImageView *yyImageView = [[YYAnimatedImageView alloc] initWithImage:yyimage]; yyImageView.frame = CGRectMake(0, kScreenHeight/2, kScreenWidth, kScreenHeight/3); [self.view addSubview:yyImageView];}

加载网络的gif图

SDWebImage和YYImage的加载网络图片代码。

//download network gif image- (void)downloadNetworkGifImage{ //sdwebimage [self labelFactoryWithFrame:CGRectMake(0, 80, kScreenWidth, 20) title:@"SDWebImage"]; FLAnimatedImageView *sdImageView = [[FLAnimatedImageView alloc] initWithFrame:CGRectMake(0, 100, kScreenWidth, kScreenHeight/3)]; [sdImageView sd_setImageWithURL:[NSURL URLWithString:@"/tupian/20230522/404.html [self.view addSubview:sdImageView]; //yyImage show gif image [self labelFactoryWithFrame:CGRectMake(0, kScreenHeight/2 - 20, kScreenWidth, 20) title:@"yyImage"]; YYImage *yyimage = [YYImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"/tupian/20230522/404.html YYAnimatedImageView *yyImageView = [[YYAnimatedImageView alloc] initWithImage:yyimage]; yyImageView.frame = CGRectMake(0, kScreenHeight/2, kScreenWidth, kScreenHeight/3); [self.view addSubview:yyImageView];}- (void)labelFactoryWithFrame:(CGRect)frame title:(NSString *)title{ UILabel *label = [[UILabel alloc] initWithFrame:frame]; label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor blackColor]; label.font = [UIFont systemFontOfSize:14]; label.text = title; [self.view addSubview:label];}

Podfile文件内容

platform :ios, '10.0'inhibit_all_warnings!target 'GifDemo' dopod 'YYImage'pod 'SDWebImage/GIF'pod 'FLAnimatedImage'end

感谢你能够认真阅读完这篇文章,希望小编分享的“iOS中如何显示gif图”这篇文章对大家有帮助,同时也希望大家多多支持创新互联网站建设公司,,关注创新互联行业资讯频道,更多相关知识等着你来学习!

网页标题:iOS中如何显示gif图-创新互联
本文来源:https://www.cdcxhl.com/article36/ecepg.html

成都网站建设公司_创新互联,为您提供做网站电子商务关键词优化域名注册手机网站建设网站设计

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都定制网站建设