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