Wie drehe ich ein Bild in der iPhone Programmierung?Wie drehe ich ein Bild auf dem iPhone?
1
A
Antwort
0
Sie können eine Ansicht mit einer CCGAffineTransform drehen. Sie können eine Rotationsmatrix erstellen, indem Sie die Gradzahl im Bogenmaß angeben, die Sie drehen möchten, und dann die Rotationsmatrix als Transformationseigenschaft Ihrer Ansicht festlegen.
2
Eine große Rotation und Bild UIImage Kategorie von Allen Brunson ist hier zu finden: http://www.platinumball.net/blog/2010/01/31/iphone-uiimage-rotation-and-scaling/
+0
Danke für den tollen Link :). –
1
image.transform = CGAffineTransformMakeRotation(3.142);
dreht es um 180 Grad.
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)
Dupe? http://stackoverflow.com/questions/917713/uiimage-rotation-custom-degrees – crashmstr
Könnte ein Betrogener sein, aber hängt davon ab, was das OP eigentlich machen möchte. Raju, was ist das Ziel? Meinst du "erhalten Sie eine Kopie eines UIImage, das gedreht wird?" Oder vielleicht "ein Bild gedreht anzeigen?" Oder vielleicht "animiere eine Bilddrehung?" Das sind sehr vage Fragen. –
Dies könnte auch ähnlich sein, was er fragt: http://stackoverflow.com/questions/839296/how-can-irotate-a-uiimageview-with-respect-to-any-point-other-than-its -center –