diff --git a/Examples/SDWebImage OSX Demo/ViewController.m b/Examples/SDWebImage OSX Demo/ViewController.m index 20477147..270f4cdf 100644 --- a/Examples/SDWebImage OSX Demo/ViewController.m +++ b/Examples/SDWebImage OSX Demo/ViewController.m @@ -29,13 +29,16 @@ // For animated GIF rendering, set `animates` to YES or will only show the first frame self.imageView2.animates = YES; // `SDAnimatedImageRep` can be used for built-in `NSImageView` to support better GIF & APNG rendering as well. No need `SDAnimatedImageView` - self.imageView3.animates = YES; self.imageView4.animates = YES; + + // NSImageView + Static Image self.imageView1.sd_imageIndicator = SDWebImageProgressIndicator.defaultIndicator; [self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg"] placeholderImage:nil options:SDWebImageProgressiveLoad]; + // NSImageView + Animated Image [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"https:raw.githubusercontent.com/onevcat/APNGKit/master/TestImages/APNG-cube.apng"]]; - [self.imageView3 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"]]; - self.imageView4.wantsLayer = YES; + // SDAnimatedImageView + Static Image + [self.imageView3 sd_setImageWithURL:[NSURL URLWithString:@"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png"]]; + // SDAnimatedImageView + Animated Image self.imageView4.sd_imageTransition = SDWebImageTransition.fadeTransition; [self.imageView4 sd_setImageWithURL:[NSURL URLWithString:@"http://littlesvr.ca/apng/images/SteamEngine.webp"] placeholderImage:nil options:SDWebImageForceTransition]; diff --git a/SDWebImage/SDAnimatedImageView.m b/SDWebImage/SDAnimatedImageView.m index e898362b..5c863e74 100644 --- a/SDWebImage/SDAnimatedImageView.m +++ b/SDWebImage/SDAnimatedImageView.m @@ -678,6 +678,17 @@ static NSUInteger SDDeviceFreeMemory() { [super updateLayer]; } } + +- (BOOL)wantsUpdateLayer { + // AppKit is different from UIKit, it need extra check before the layer is updated + // When we use the custom animation, the layer.setNeedsDisplay is directly called from display link (See `displayDidRefresh:`). However, for normal image rendering, we must implements and return YES to mark it need display + if (_currentFrame) { + return NO; + } else { + return YES; + } +} + #endif