iOS7以后,苹果公司提供了一种实时毛玻璃的渲染效果,苹果提供了一些方法让我们可以在UIImage上增加毛玻璃效果,但是,只是静态的效果,不是实时的,要是想要实时的效果,那该怎么办呢?
上代码:(很简单)
1 //初始化imageView 2 UIImageView * imageview = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"psb.png"]]; 3 imageview.userInteractionEnabled = YES; 4 imageview.contentMode = UIViewContentModeScaleAspectFit; 5 imageview.frame = CGRectMake(0, 80, 320, 320); 6 [self.view addSubview:imageview]; 7 8 //实现模糊效果 9 UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 10 UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur]; 11 effectview.frame = CGRectMake(0, 0, imageview.frame.size.width, 320); 12 [imageview addSubview:effectview];
是不是很简单