思路
显示一张图片,再是加模糊层(设置透明度),最后放小图标(和底图一样)
- 下面(最底下的图片要和模糊层的frame保持一致)
<1>.模糊层下面的图片
UIImageView *_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 100)]; _imageView.image = [UIImage imageNamed:@"0xxx0006.jpg"]; [self.view addSubview:_imageView];
- <2>.模糊层(
lightView.alpha = 0.9f
;自己设置)
UIBlurEffect *light = [UIBlurEffect effectWithStyle:(UIBlurEffectStyleLight)]; //模糊效果的View视图 UIVisualEffectView *lightView = [[UIVisualEffectView alloc] initWithEffect:light]; lightView.frame = CGRectMake(0, 0, WIDTH, 100); //添加上去 [self.view addSubview:lightView]; //模糊透明度 0-1 1,特别模糊 //加上它后,按钮也会变暗 lightView.alpha = 0.9f; <3>.模糊层 UIImageView *geView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 20, 60,60)]; geView.image = [UIImage imageNamed:@"0xxx0006.jpg"]; geView.layer.cornerRadius = 30; geView.layer.masksToBounds = YES; [lightView addSubview:geView];
- 大家掌握3点:
1.底图的frame
和模糊层frame
保持一致
2.底图的图片和自己设置的圆的小图标保持一致
3.模糊的6句代码
(1).创建类UIBlurEffect UIBlurEffect *light = [UIBlurEffect effectWithStyle:(UIBlurEffectStyleLight)]; (2).模糊效果的View视图 UIVisualEffectView *lightView = [[UIVisualEffectView alloc] initWithEffect:light]; (3).设置frame lightView.frame = CGRectMake(0, 0, WIDTH, 100); (4).添加上去 [self.view addSubview:lightView]; (5).模糊透明度 0-1 1,特别模糊 (加上它后,按钮也会变暗) lightView.alpha = 0.9f;