I have a UIImageView and I wanted to add a black overlay on top of it. What is the best way of doing this without having to override drawRect? I was thinking of adding a CALayer
Swift 5 Version:
func addOverlay(on view: UIView) { let overlay: UIView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height)) overlay.backgroundColor = UIColor.gray view.addSubview(overlay) }