After autolayout (Constraints) How to make corner radius and shadow of the view ( even the view have some subview also ) and which method to write the code. If i write the code in viewdidload , viewDidAppear that i cant get the exact corner radius and shadow ?
This is my code which I do in viewWillLayoutSubview , I can get the corner radius but I cannot get shadow effects. If I remove view.layer.masksToBounds = true I can get shadow but its not corner only for base view not for its subviews ..
view.layer.cornerRadius = 10
view.layer.masksToBounds = true
view.layer.borderWidth = 1.0
view.layer.borderColor = UIColor.black.cgColor
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOffset = CGSize(width: 3, height: 3)
view.layer.shadowOpacity = 0.7
view.layer.shadowRadius = 4.0
viewShadow.layer.cornerRadius = 12
viewShadow.layer.masksToBounds = true;
viewShadow.backgroundColor = UIColor.white
viewShadow.layer.shadowColor = UIColor.lightGray.cgColor
viewShadow.layer.shadowOpacity = 0.8
viewShadow.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
viewShadow.layer.shadowRadius = 6.0
viewShadow.layer.masksToBounds = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With