The code below prints a line on a UIView. I just want to know the code that I would write to be able to insert an image on top of the view. Many people will point to this question but it does not work. I have tried it several times. The code I tried below is having no effect.
class ViewController: UIViewController {
var canVasView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
let myLayer = CALayer()
let myImage = UIImage(named: "star")?.cgImage
myLayer.frame = CGRect(x: 0, y: 0, width: 60, height: 60)
myLayer.contents = myImage
canVasView.layer.addSublayer(myLayer)
}
}