美文网首页
iOS 模糊效果

iOS 模糊效果

作者: 阿拉灯神钉 | 来源:发表于2018-11-12 11:37 被阅读6次
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            CIContext *context = [CIContext contextWithOptions:nil];
            CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage];
            CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
            [filter setValue:ciImage forKey:kCIInputImageKey];
            /// 模糊程度
            [filter setValue:@15.0f forKey: @"inputRadius"];
            CIImage *result = [filter valueForKey:kCIOutputImageKey];
            CGImageRef outImage = [context createCGImage: result fromRect:ciImage.extent];
            UIImage *blurImage = [UIImage imageWithCGImage:outImage];
            dispatch_async(dispatch_get_main_queue(), ^{
                self.iconBGView.image = blurImage;
            });
        });
    

    相关文章

      网友评论

          本文标题:iOS 模糊效果

          本文链接:https://www.haomeiwen.com/subject/nciqfqtx.html