UIImage+ImageEffects中的CGContextD

2019-06-11  本文已影响0人  Maj_sunshine

发现现象

出现原因

Simulator Screen Shot - iPhone 6 - 2019-06-11 at 22.39.51.png

解决

- (void)setEffectImage:(UIImage *)effectImage imageStr:(NSString *)imageStr color:(UIColor *)color {
    static pthread_mutex_t pLock;
    pthread_mutex_init(&pLock, NULL);
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        pthread_mutex_lock(&pLock);
        UIImage *image = nil;
        if (color) {
            image = [effectImage applyTintEffectWithColor:color];
        } else {
            image = [effectImage applyDarkEffect];
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            self.image = image;
            NSString *key = imageStr;
            if (addMeari) {
                key = [imageStr stringByAppendingString:@"meari"];
            }
            [[SDImageCache sharedImageCache] storeImage:image forKey:key toDisk:YES];
            pthread_mutex_unlock(&pLock);
        });
    });
}
上一篇下一篇

猜你喜欢

热点阅读