在这里,我声明了UIView,并添加了具有清晰颜色的边框和具有黑色的阴影。 但是,由于我没有任何阴影,因此它似乎不起作用。
将view.clipsToBounds = true
更改为view.clipsToBounds = false
和
view.layer.masksToBounds = true
至view.layer.masksToBounds = false
无法解决问题
var backView: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.layer.cornerRadius = 15
view.clipsToBounds = true
view.layer.masksToBounds = true
view.layer.borderColor = UIColor.clear.cgColor
view.layer.borderWidth = 0.3
view.layer.shadowOpacity = 0.5
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowRadius = 15.0
view.layer.shadowOffset = CGSize(width: 5, height: 5)
view.layer.shadowPath = UIBezierPath(rect: view.bounds).cgPath
return view
}()