title: How to insert image over uiview
body: <p>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 <a href="https://stackoverflow.com/questions/48180635/how-to-insert-image-on-uiview">point to this question</a> but it does not work. I have tried it several times. The code I tried below is having no effect. </p>
  
  <pre><code>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)
      }
  }
  </code></pre>