Add Shadow To Specific Corner Of Uiview With Shadow Swift

[Solved] Add Shadow To Specific Corner Of Uiview With Shadow Swift | Swift - Code Explorer | yomemimo.com
Question : add shadow to specific corner of UIView with shadow swift 6 site:stackoverflow.com

Answered by : repulsive-reindeer-e2ue4tk3ws7q

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)

Source : https://stackoverflow.com/questions/51783502/add-shadow-and-corners-to-uiview-except-the-bottom | Last Update : Wed, 14 Apr 21

Answers related to add shadow to specific corner of uiview with shadow swift 6 site stackoverflow com

Code Explorer Popular Question For Swift