35 lines
795 B
Objective-C
35 lines
795 B
Objective-C
//
|
|
// UIImageView+Vague.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/27.
|
|
//
|
|
|
|
#import "UIImageView+Vague.h"
|
|
#import "UIImage+ImageEffects.h"
|
|
@implementation UIImageView (Vague)
|
|
|
|
/// 模糊的效果
|
|
/// @param image 需要模糊的图片
|
|
/// @param blurRadius 角度 越大 模糊的越明显 默认20
|
|
- (void)setImageToBlur:(UIImage *)image
|
|
blurRadius:(CGFloat)blurRadius {
|
|
NSParameterAssert(image);
|
|
if (blurRadius < 0) {
|
|
blurRadius = 20;
|
|
}
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
UIImage *blurredImage = [image applyBlurWithRadius:blurRadius
|
|
tintColor:nil
|
|
saturationDeltaFactor:1.8
|
|
maskImage:nil];
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
self.image = blurredImage;
|
|
});
|
|
});
|
|
}
|
|
|
|
@end
|