
blurEffView渐变毛玻璃View的懒加载
使用时候
[self.view addSubview:self.blurEffView];
- (UIVisualEffectView *)blurEffView{
if (_blurEffView == nil) {
_blurEffView = [[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
_blurEffView.frame = CGRectMake(0, 411 * ratio, screenWidth, 125 * ratio);
_blurEffView.alpha = 1.0f;
_blurEffView.backgroundColor = [UIColor clearColor];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = _blurEffView.bounds;
gradientLayer.colors = @[(__bridge id)[UIColor clearColor].CGColor,
(__bridge id)[UIColor whiteColor].CGColor,
(__bridge id)[UIColor lightGrayColor].CGColor];
gradientLayer.locations = @[@(0.0),@(0.8)];
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(0, 1);
_blurEffView.layer.mask = gradientLayer;
}
return _blurEffView;
}
网友评论