iOS Layer 阴影效果不显示问题

设置阴影时,又去设置 masksToBounds = true 阴影效果就不会显示。

        let shadowView = UIView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
        shadowView.backgroundColor = .yellow
        shadowView.layer.shadowColor = UIColor.black.cgColor
        shadowView.layer.shadowOffset = CGSize(width: 5, height: 5)
        shadowView.layer.shadowOpacity = 1
        shadowView.layer.shadowRadius = 10
        
        shadowView.layer.cornerRadius = 5
        //  设置阴影 又同时设置 masksToBounds 会被裁剪掉,效果不显示
        // shadowView.layer.masksToBounds = true
        view.addSubview(shadowView)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容