标签:uivisualeffectview ios 模糊效果 玻璃效果
在需要模糊的UIView上,添加一个UIVisualEffectView对象即可,若直接在storyboad里面直接加UIVisualEffectView,你的项目必须是iOS8以上才能用
- (void)viewDidLoad {
[super viewDidLoad];
// UIImageView *imageview = [[UIImageView alloc] init];
//
// imageview.frame = CGRectMake(10, 200, 300, 300);
//
// imageview.image = [UIImage imageNamed:@"2"];
//
// imageview.contentMode = UIViewContentModeScaleAspectFit;
//
// imageview.userInteractionEnabled = YES;
//
// [self.view addSubview:imageview];
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
// effectview.frame = CGRectMake(0, 0, imageview.frame.size.width/2, 300);
effectview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
//[imageview addSubview:effectview];
[self.view addSubview:effectview];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(10, 50, 100, 40);
[btn setTitle:@"btn" forState:UIControlStateNormal];
[effectview.contentView addSubview:btn];
}
iOS8 模糊视图(毛玻璃效果) UIVisualEffectView
标签:uivisualeffectview ios 模糊效果 玻璃效果
原文地址:http://blog.csdn.net/sammyieveo/article/details/45933219