gpt4 book ai didi

ios - 如何让 gif 在 UIWebView 中永不停止?

转载 作者:行者123 更新时间:2023-11-29 02:30:52 24 4
gpt4 key购买 nike

我在 UIWebView 中有一个 Gif,但是当动画结束时,它就停止了。我该怎么做才能永不止步?

这是我的代码:

self.video 是我的 UiWebView我的 gif 是 videoGif.gif

- (void)viewDidLoad
{
[super viewDidLoad];
self.video.delegate=self;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"videoGif" ofType:@"gif"];

NSData *gif = [NSData dataWithContentsOfFile:filePath];
[self.video loadData:gif MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];

self.video.userInteractionEnabled = NO;
self.video.scalesPageToFit=YES;
self.video.contentMode = UIViewContentModeScaleAspectFit;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
self.video.scalesPageToFit=YES;
self.video.contentMode = UIViewContentModeScaleAspectFit;
}

谢谢!!

最佳答案

您可以使用 UIView 动画。这里我使用 UIButton 来制作动画。这可能是另一种方式。这是我的代码:

NSMutableArray *imageArray=[NSMutableArray new];
for(int i=1;i<=16;i++){
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"win_%d.png",i]]];
}
[animatedButton setImage:[UIImage imageNamed:@"win_1.png"] forState:UIControlStateNormal];
[animatedButton.imageView setAnimationImages:[imageArray copy]];
animatedButton.imageView.animationDuration = .50;
[animatedButton.imageView startAnimating];

关于ios - 如何让 gif 在 UIWebView 中永不停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26892744/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com