UIVisualEffectView就是大家常说的毛玻璃,我简单的介绍一下他的三种样式:
1.UIBlurEffectStyleDark
Dark.png2.UIBlurEffectStyleExtraLight
ExtraLight.png3.UIBlurEffectStyleLight
Light.png以上是这三种样式呈现出的界面,个人感觉还是第三种(UIBlurEffectStyleLight)的效果比较好!
下面上一下代码:
#pragma mark-->快速创建UIVisualEffectView的方法
- (void)setupUIVisualEffectViewStyle:(UIBlurEffectStyle)style andSize:(CGRect)rect {
UIVisualEffectView *visualEffect = [[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:style]];
visualEffect.frame = rect;
[self.view addSubview:visualEffect];
UIImageView *ima = [[UIImageView alloc]init];
ima.image = [UIImage imageNamed:@"hjgh8"];
ima.center = CGPointMake(visualEffect.bounds.size.width/2, visualEffect.bounds.size.height/2);
ima.bounds = CGRectMake(0, 0, 100, 50);
[visualEffect addSubview:ima];
}
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hjgh8"]];
[self.view addSubview:image];
image.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
//UIBlurEffectStyleDark
[self setupUIVisualEffectViewStyle:UIBlurEffectStyleDark andSize:CGRectMake(0, 30, self.view.bounds.size.width, 100)];
//UIBlurEffectStyleExtraLight
[self setupUIVisualEffectViewStyle:UIBlurEffectStyleExtraLight andSize:CGRectMake(0, 230, self.view.bounds.size.width, 100)];
//UIBlurEffectStyleLight
[self setupUIVisualEffectViewStyle:UIBlurEffectStyleLight andSize:CGRectMake(0, 430, self.view.bounds.size.width, 100)];
}
希望此篇文章对大家有所帮助!
网友评论