Answers for "how to set a shadow of uiview in swift 4"

0

add shadow to specific corner of UIView with shadow swift 6 site:stackoverflow.com

let containerV = UIView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width , height: 50))
containerV.clipsToBounds = false
containerV.layer.shadowColor = UIColor.black.cgColor
containerV.layer.shadowOpacity = 1 
containerV.layer.shadowOffset = CGSize(width: -0.5, height: -3.0) 
/* since we dont want shadow at bottom */
containerV.layer.shadowRadius = 2
containerV.layer.shadowPath = UIBezierPath(roundedRect: containerV.bounds, 
cornerRadius: 10).cgPath

let headerLabel  = UILabel()
headerLabel.frame = containerV.bounds
headerLabel.text = "Test Header"
headerLabel.backgroundColor = UIColor.white

headerLabel.clipsToBounds = true
headerLabel.layer.cornerRadius = 10
if #available(iOS 11.0, *) {
        headerLabel.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
    } else {
        // Fallback on earlier versions
    }
containerV.addSubview(headerLabel)
Posted by: Guest on April-07-2021

Code answers related to "how to set a shadow of uiview in swift 4"

Code answers related to "Swift"

Browse Popular Code Answers by Language