//If someone needs in swift 3
func rotateImageClockWise(theImage: UIImage,imageView:UIImageView) -> UIImage {
var orient: UIImageOrientation!
let imgOrientation = theImage.imageOrientation
UIView.transition(with: imageView, duration: 0.2, options: .transitionCrossDissolve, animations: {() -> Void in
switch imgOrientation {
case .left:
orient = .up
case .right:
orient = .down
case .up:
orient = .right
case .down:
orient = .left
case .upMirrored:
orient = .rightMirrored
case .downMirrored:
orient = .leftMirrored
case .leftMirrored:
orient = .upMirrored
case .rightMirrored:
orient = .downMirrored
}
}, completion: { _ in })
let rotatedImage = UIImage(cgImage: theImage.cgImage!, scale: 1.0, orientation: orient)
return rotatedImage
}
//Just call the method like this :
rotateImageClockWise(theImage: UIImage,imageView:UIImageView)