Merge pull request #1975 from dreampiggy/mac_animate_gif
support animated GIF on macOS
This commit is contained in:
commit
3d7b6c1bf6
|
@ -27,6 +27,8 @@
|
|||
// NOTE: https links or authentication ones do not work (there is a crash)
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
// For animated GIF rendering, set `animates` to YES or will only show the first frame
|
||||
self.imageView1.animates = YES;
|
||||
[self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"http://assets.sbnation.com/assets/2512203/dogflops.gif"]];
|
||||
[self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"http://www.ioncannon.net/wp-content/uploads/2011/06/test2.webp"]];
|
||||
[self.imageView3 sd_setImageWithURL:[NSURL URLWithString:@"http://littlesvr.ca/apng/images/SteamEngine.webp"]];
|
||||
|
|
|
@ -92,7 +92,7 @@ imageView.sd_setImage(with: URL(string: "http://www.domain.com/path/to/image.jpg
|
|||
- If you use cocoapods, add `pod 'SDWebImage/GIF'` to your podfile.
|
||||
- To use it, simply make sure you use `FLAnimatedImageView` instead of `UIImageView`.
|
||||
- **Note**: there is a backwards compatible feature, so if you are still trying to load a GIF into a `UIImageView`, it will only show the 1st frame as a static image.
|
||||
- **Important**: FLAnimatedImage only works on the iOS platform, so for all the other platforms (OS X, tvOS, watchOS) we will fallback to the backwards compatibility feature described above
|
||||
- **Important**: FLAnimatedImage only works on the iOS platform. For OS X, use `NSImageView` with `animates` set to `YES` to show the entire animated images and `NO` to only show the 1st frame. For all the other platforms (tvOS, watchOS) we will fallback to the backwards compatibility feature described above
|
||||
|
||||
## Common Problems
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
if (!data) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
#if SD_MAC
|
||||
return [[UIImage alloc] initWithData:data];
|
||||
#endif
|
||||
|
||||
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
|
||||
|
||||
|
@ -42,8 +46,6 @@
|
|||
#if SD_UIKIT || SD_WATCH
|
||||
UIImage *frameImage = [UIImage imageWithCGImage:CGImage scale:scale orientation:UIImageOrientationUp];
|
||||
staticImage = [UIImage animatedImageWithImages:@[frameImage] duration:0.0f];
|
||||
#elif SD_MAC
|
||||
staticImage = [[UIImage alloc] initWithCGImage:CGImage size:NSZeroSize];
|
||||
#endif
|
||||
CGImageRelease(CGImage);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue