diff --git a/SDWebImage/Core/SDImageAPNGCoder.m b/SDWebImage/Core/SDImageAPNGCoder.m index 5d2b7321..a0700abb 100644 --- a/SDWebImage/Core/SDImageAPNGCoder.m +++ b/SDWebImage/Core/SDImageAPNGCoder.m @@ -14,20 +14,15 @@ #endif // iOS 8 Image/IO framework binary does not contains these APNG contants, so we define them. Thanks Apple :) -static NSString * kSDCGImagePropertyAPNGLoopCount = @"LoopCount"; -static NSString * kSDCGImagePropertyAPNGDelayTime = @"DelayTime"; -static NSString * kSDCGImagePropertyAPNGUnclampedDelayTime = @"UnclampedDelayTime"; +// We can not use runtime @available check for this issue, because it's a global symbol and should be loaded during launch time by dyld. So hack if the min deployment target version < iOS 9.0, whatever it running on iOS 9+ or not. +#if (__IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) +const CFStringRef kCGImagePropertyAPNGLoopCount = (__bridge CFStringRef)@"LoopCount"; +const CFStringRef kCGImagePropertyAPNGDelayTime = (__bridge CFStringRef)@"DelayTime"; +const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef)@"UnclampedDelayTime"; +#endif @implementation SDImageAPNGCoder -+ (void)initialize { - if (@available(iOS 9, *)) { - kSDCGImagePropertyAPNGLoopCount = (__bridge NSString *)kCGImagePropertyAPNGLoopCount; - kSDCGImagePropertyAPNGDelayTime = (__bridge NSString *)kCGImagePropertyAPNGDelayTime; - kSDCGImagePropertyAPNGUnclampedDelayTime = (__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime; - } -} - + (instancetype)sharedCoder { static SDImageAPNGCoder *coder; static dispatch_once_t onceToken; @@ -52,15 +47,15 @@ static NSString * kSDCGImagePropertyAPNGUnclampedDelayTime = @"UnclampedDelayTim } + (NSString *)unclampedDelayTimeProperty { - return kSDCGImagePropertyAPNGUnclampedDelayTime; + return (__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime; } + (NSString *)delayTimeProperty { - return kSDCGImagePropertyAPNGDelayTime; + return (__bridge NSString *)kCGImagePropertyAPNGDelayTime; } + (NSString *)loopCountProperty { - return kSDCGImagePropertyAPNGLoopCount; + return (__bridge NSString *)kCGImagePropertyAPNGLoopCount; } + (NSUInteger)defaultLoopCount {