[英]UIView shadow, cornerradius not working
@IBOutlet weak var selectorSemiView: UIView!
@IBOutlet weak var blurEffect: UIVisualEffectView!
@IBOutlet var outerAreaRecognizer: UITapGestureRecognizer!
override func viewDidLoad() {
super.viewDidLoad()
selectorSemiView.layer.cornerRadius = 15
selectorSemiView.layer.shadowColor = UIColor.gray.cgColor
selectorSemiView.layer.shadowOffset = CGSize.zero
selectorSemiView.layer.shadowRadius = 7
}
selectorSemiView is a container view selectorSemiView是一个容器视图
When I run this app, there is no shadow and no rounded corner. 当我运行这个应用程序时,没有阴影,也没有圆角。
What's wrong in my code? 我的代码有什么问题?
your code is fine but you forget to set the opacity, if you need the more information you can get the another answer in SO , for eg 你的代码很好,但你忘了设置不透明度,如果你需要更多信息,你可以在SO中得到另一个答案,例如
selectorSemiView.layer.cornerRadius = 15
selectorSemiView.layer.shadowColor = UIColor.gray.cgColor
selectorSemiView.layer.shadowOffset = CGSize.zero
selectorSemiView.layer.shadowOpacity = 1.0
selectorSemiView.layer.shadowRadius = 7.0
selectorSemiView.layer.masksToBounds = false
output 产量
你需要添加
selectorSemiView.clipsToBounds = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.