标签:
在须要模糊的UIView上。加入一个UIVisualEffectView对象就可以。
效果例如以下图:
代码例如以下:
UIImageView *imageview = [[UIImageViewalloc] init];
imageview.frame =CGRectMake(10,100, 300, 300);
imageview.image = [UIImageimageNamed:@"2"];
imageview.contentMode =UIViewContentModeScaleAspectFit;
imageview.userInteractionEnabled =YES;
[self.viewaddSubview:imageview];
UIBlurEffect *blur = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectview = [[UIVisualEffectViewalloc] initWithEffect:blur];
effectview.frame =CGRectMake(0,0, imageview.size.width/2,300);
[imageviewaddSubview:effectview];
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeSystem];
btn.frame =CGRectMake(10,50, 100, 40);
[btn setTitle:@"btn"forState:UIControlStateNormal];
[effectview.contentViewaddSubview:btn];
iOS开发交流群361513739
iOS 8 模糊视图(毛玻璃效果)的简单实现UIVisualEffectView
标签:
原文地址:http://www.cnblogs.com/gcczhongduan/p/5217586.html