//添加一个图片
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];
版权声明:本文为博主原创文章,未经博主允许不得转载。