美文网首页iOS劝退指南
渐变毛玻璃效果

渐变毛玻璃效果

作者: MccReeee | 来源:发表于2016-09-20 17:06 被阅读76次
Paste_Image.png

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;
}

相关文章

网友评论

    本文标题:渐变毛玻璃效果

    本文链接:https://www.haomeiwen.com/subject/nieoettx.html