Merge pull request #3636 from dreampiggy/bugfix/ios17_animatedimageview_render_issue_background_foreground

Fix the iOS 17 UIKit issue that UIImageView entering the background will reset CALayer's contents, which cause SDAnimatedImageView render issue (out-of-sync)
This commit is contained in:
DreamPiggy 2023-11-15 16:07:36 +08:00 committed by GitHub
commit 526ec84183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -501,6 +501,17 @@
}
}
#if SD_UIKIT
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
// See: #3635
// From iOS 17, when UIImageView entering the background, it will receive the trait collection changes, and modify the CALayer.contents by `self.image.CGImage`
// However, For animated image, `self.image.CGImge != self.currentFrame.CGImage`, right ?
// So this cause the render issue, we need to reset the CALayer.contents again
[super traitCollectionDidChange:previousTraitCollection];
[self.imageViewLayer setNeedsDisplay];
}
#endif
#if SD_MAC
// NSImageView use a subview. We need this subview's layer for actual rendering.
// Why using this design may because of properties like `imageAlignment` and `imageScaling`, which it's not available for UIImageView.contentMode (it's impossible to align left and keep aspect ratio at the same time)