title: Add and Center image inside CALayer
body: <p>I want to center the image inside a CALayer. Even the image size must be modified accordingly and color of image should also be tinted. The problem is Im not able to set the image size and even add color.</p>
  
  <pre><code>    //premium gradient
      let premiumViewLayer=CALayer()
      premiumViewLayer.bounds=CGRect(x:0, y:0, width:(getGradientWidth()), height:(LKView.bounds.height))
      premiumViewLayer.backgroundColor = UIColor.clear.cgColor
  
      let premiumimageViewLayer=CALayer()
      premiumimageViewLayer.frame = SSView.frame
      premiumimageViewLayer.contents=UIImage(named: "premium")?.cgImage
      premiumimageViewLayer.contentsGravity = kCAGravityCenter
  
      premiumViewLayer.addSublayer(premiumimageViewLayer)
  </code></pre>
  
  <p>I want to achieve something like below:
  <a href="https://i.stack.imgur.com/JeehV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JeehV.jpg" alt="image"></a></p>