How to rotate an image 90 degrees on iOS?

后端 未结 14 1915
野的像风
野的像风 2020-11-29 00:55

What I want to do is take a snapshot from my camera , send it to a server and then the server sends me back the image on a viewController. If the image is in portrait mode t

14条回答
  •  青春惊慌失措
    2020-11-29 01:41

    Swift 3 and Swift 4 use .pi instead

    eg:

    //rotate 90 degrees
    myImageView.transform = CGAffineTransform(rotationAngle: .pi / 2)
    
    //rotate 180 degrees
    myImageView.transform = CGAffineTransform(rotationAngle: .pi)
    
    //rotate 270 degrees
    myImageView.transform = CGAffineTransform(rotationAngle: .pi * 1.5)
    

提交回复
热议问题