How to display gif Diagram in iOS
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!