#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIImageView *bgImage;//背景
@property (nonatomic, strong) UIVisualEffectView *visualEffectView;//背景的模糊效果
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.bgImage];
}
-(UIImageView *)bgImage{
if (!_bgImage) {
_bgImage = [[UIImageView alloc] initWithFrame:self.view.bounds];
_bgImage.image = [UIImage imageNamed:@"timg"];
//模糊的效果
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blur];
visualEffectView.frame = _bgImage.frame;
_visualEffectView = visualEffectView;
[_bgImage addSubview:visualEffectView];
}
return _bgImage;
}
原图
效果图
网友评论