如何在 iPhone 编程中旋转图像?
问问题
13654 次
4 回答
2
可以在这里找到 Allen Brunson 的出色旋转和图像 UIImage 类别: http ://www.platinumball.net/blog/2010/01/31/iphone-uiimage-rotation-and-scaling/
于 2009-11-15T11:23:32.677 回答
1
image.transform = CGAffineTransformMakeRotation(3.142);
将其旋转 180 度。
于 2011-10-30T15:44:13.807 回答
0
您可以使用 CCGAffineTransform 旋转视图。您可以通过指定要旋转的弧度度数来创建旋转矩阵,然后将旋转矩阵设置为视图的 .transform 属性。
于 2009-06-09T13:36:18.847 回答
0
//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)
于 2017-08-24T13:24:47.670 回答