制作毛玻璃效果
Posted liguangsunls
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了制作毛玻璃效果相关的知识,希望对你有一定的参考价值。
//加入一个图片
UIImageView *imageview = [[UIImageView alloc]init];
imageview.frame = CGRectMake(10, 100, 300, 300);
imageview.contentMode = UIViewContentModeScaleAspectFit;
imageview.userInteractionEnabled = YES;
imageview.image = [UIImage imageNamed:@"3.jpg"];
[self.view addSubview:imageview];
//模糊效果代码
UIBlurEffect *errect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
UIVisualEffectView *ectView = [[UIVisualEffectView alloc]initWithEffect:errect];
ectView.alpha = 0.6;
ectView.frame = CGRectMake(0, 0, imageview.frame.size.width/2, 300);
[imageview addSubview:ectView];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame =CGRectMake(10,50, 100, 40);
[btn setTitle:@"btn"forState:UIControlStateNormal];
[ectView.contentView addSubview:btn];
UIImageView *imageview = [[UIImageView alloc]init];
imageview.frame = CGRectMake(10, 100, 300, 300);
imageview.contentMode = UIViewContentModeScaleAspectFit;
imageview.userInteractionEnabled = YES;
imageview.image = [UIImage imageNamed:@"3.jpg"];
[self.view addSubview:imageview];
//模糊效果代码
UIBlurEffect *errect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
UIVisualEffectView *ectView = [[UIVisualEffectView alloc]initWithEffect:errect];
ectView.alpha = 0.6;
ectView.frame = CGRectMake(0, 0, imageview.frame.size.width/2, 300);
[imageview addSubview:ectView];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame =CGRectMake(10,50, 100, 40);
[btn setTitle:@"btn"forState:UIControlStateNormal];
[ectView.contentView addSubview:btn];
以上是关于制作毛玻璃效果的主要内容,如果未能解决你的问题,请参考以下文章