Suppose you have a CALayer
subclass as part of your view hierarchy, which has been created with a scale and rotation transform, where the angle and scale is only defined at runtime, i.e:
let layer = CALayer()
layer.frame = CGRect(x: 10, y: 10, width: 100, height: 100)
//where xx and yy are some precomputed values
layer.transform = CATransform3DConcat(CATransform3DMakeScale(xx, xx, 1),
CATransform3DMakeRotation(yy, 0, 0, 1))
let view = UIView() //your view hierarchy
view.addSublayer(layer)
Later in the program, I want to rotate this layer to a specific angle. How do I specify the transform so that
- A) The original scale applied to the layer is preserved
- B) The original rotation applied to the layer is discarded and reset to the new value?
let angle = CGFloat.pi/3
layer.transform = ???