0

So I have this simple problem where I need to rotate a CALayer 90 degrees. The problem is however, that it seems none of the methods I have found from research actually do anything. Below is the code I am using where imgLayer is a CALayer

var transform = CATransform3DIdentity
transform = CATransform3DRotate(transform, (CGFloat(Double.pi/2)), 0, 1, 0)
imgLayer.transform = transform

From what I have read this code should work but it does not seem to have any affect at all and I was wondering whether anyone had any suggestions as to why this is the case. Any help on the topic would be greatly appreciated, thank you.

Regards, Nick

rmaddy
  • 314,917
  • 42
  • 532
  • 579
imjonu
  • 515
  • 1
  • 6
  • 12

1 Answers1

1

You can first set your image in imageView and rotate get your image in imageView

Here:

    let customImageView = UIImageView()
    customImageView.frame = CGRect.init(x: 0, y: 0, w: 250, h: 250)
    customImageView.image = UIImage(named: "yourImage")

    customImageView .transform = customImageView .transform.rotated(by: CGFloat.init(M_PI_2))
    var rotatedImage = UIImage()
    rotatedImage = customImageView.image!
Okan
  • 410
  • 4
  • 10