簡體   English   中英

如何在UIImageView iOS中使用gif圖像

[英]how to use gif images in UIImageView iOS

我有一個有4個圖像的gif圖像文件,我喜歡在UIImage視圖中逐個顯示這些圖像的image.animation。 請指導是否可以顯示或使用替代告訴我。

謝謝 。

FLAnimatedImage是適用於iOS的高性能開源動畫GIF引擎:

  • 同時播放多個GIF,播放速度可與桌面瀏覽器相媲美
  • 尊重可變幀延遲
  • 在記憶壓力下表現優雅
  • 消除第一次播放循環期間的延遲或阻塞
  • 以與現代瀏覽器相同的方式解釋快速GIF的幀延遲

這是一個經過充分測試的組件,我寫的是為Flipboard中的所有GIF提供支持

它會幫助你,對於gif鏈接.. https://github.com/mayoff/uiimage-from-animated-gif更多幫助請隨時詢問

是的,它可以在iOS,這里我在下面附上一個URL。請參考這個為您的概念,即使我借助此鏈接做到了。

https://github.com/mayoff/uiimage-from-animated-gif

希望我抱着你。

試試這樣......

- (void)viewDidLoad {
        [super viewDidLoad];

        NSURL *url = [[NSBundle mainBundle] URLForResource:@"loading" withExtension:@"gif"];
        UIImage *loadingImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
        self.dataImageView.animationImages = loadingImage.images;
        self.dataImageView.animationDuration = loadingImage.duration;
        self.dataImageView.animationRepeatCount = 1;
        self.dataImageView.image = loadingImage.images.lastObject;
        [self.dataImageView startAnimating];
    }

首先,您可以將這4個圖像添加到一個Plist中,並執行以下代碼。 我希望它能奏效

    NSDictionary *picturesDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PhotesArray" ofType:@"plist"]];
NSArray *imageNames = [picturesDictionary objectForKey:@"Photos"];
NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i=0; i<[imageNames count]; i++) {
    [images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}
//Normal animation
self.dataImageView.animationImages = images;
self.dataImageView.animationDuration = 3.0;
[self.dataImageView startAnimating];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM