介紹
這里并 不 是 用到了UIVisualEffectView,畢竟iOS8.0之后才能使用。
而是。。在網(wǎng)上看見的一個分類,應(yīng)該是國外的Coder寫的吧。讓我想起了前段時間在微信朋友圈火了一下子的發(fā)紅包看模糊照片,覺得很好玩、記錄一下。
一下是效果圖:

效果圖

原圖
重點:就是一個分類,主要用到了CoreGraphics框架實現(xiàn)(其實我并沒看懂)

核心code
鏈接地址: 傳送門
如何使用
不用我貼代碼其實一看就知道了,很簡單
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.backimage = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.backimage.image = [UIImage imageNamed:@"timg.jpg"];
//開啟交互
self.backimage.userInteractionEnabled = YES;
[self.view addSubview:self.backimage];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
static BOOL isEffect = YES;
if (isEffect) {
UIImage *sourceImage = [UIImage imageNamed:@"timg.jpg"];
//一句代碼搞定毛玻璃效果
UIImage *lastImage = [sourceImage applyDarkEffect];
self.backimage.image = lastImage;
}else
{
self.backimage.image = [UIImage imageNamed:@"timg.jpg"];
}
isEffect = !isEffect;
}
OK,Get到了。