美文网首页完成需求后的反思
iOS UIView设置圆角时同时设置阴影不显示的问题处理

iOS UIView设置圆角时同时设置阴影不显示的问题处理

作者: VickyLanLan | 来源:发表于2022-03-04 11:03 被阅读0次

-(UIView*)bgView{

    if(!_bgView) {

        _bgView=[[UIViewalloc]init];

        _bgView.backgroundColor = [UIColor whiteColor];

        _bgView.layer.shadowColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:0.1].CGColor;

        _bgView.layer.shadowOffset = CGSizeMake(0, 1);

        _bgView.layer.shadowOpacity = 1;

        _bgView.layer.shadowRadius = 8;

        _bgView.layer.cornerRadius =4;

        ///maskLayer带有mask属性, 并嵌入到shaowLayer

        CALayer*maskLayer = [CALayerlayer];

        maskLayer.frame=_bgView.layer.bounds;

        maskLayer.masksToBounds=YES;

        [_bgView.layeraddSublayer:maskLayer];

    }

    return _bgView;

}

相关文章

网友评论

    本文标题:iOS UIView设置圆角时同时设置阴影不显示的问题处理

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