Swift: Add image to CAShapeLayer
I have a CAShapeLayer with a fill color, and want to add an icon in the center of this shape: var shape = CAShapeLayer() shape.fillColor = UIColor(white: 0.90, alpha: 1).CGColor var image = UIImage(named: "some_image") shape.contents = image?.CGImage This code does compile and does show the grey shape- but no image. :( I looked into these posts, but I can't cast the CGImage like they do. add UIImage in CALayer and Display an image or UIImage with a plain CALayer Is there another way? Or a workaround to the id cast? Full code: ViewController.swift import UIKit class ViewController: