iOS8 模糊视图(毛玻璃效果) UIVisualEffectView
在需要模糊的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];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。