Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to display gif Diagram in iOS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to display the gif diagram in iOS, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Show local gif diagram

SDWebImage and YYImage display local picture code.

/ / 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];}

Load the gif diagram of the network

SDWebImage and YYImage load network picture code.

/ / 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:@ "https://cache.yisu.com/upload/information/20201211/272/44763.gif"]]; [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:@ "https://cache.yisu.com/upload/information/20201211/272/44763.gif"]]]; 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 file content

Platform: ios, '10.0 percent warring target' GifDemo' dopod 'YYImage'pod' SDWebImage/GIF'pod 'FLAnimatedImage'end

Thank you for reading this article carefully. I hope the article "how to display gif Diagram in iOS" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report