1

Как повернуть изображение в iPhone?Как повернуть изображение на iPhone?

+0

Dupe? http://stackoverflow.com/questions/917713/uiimage-rotation-custom-degrees – crashmstr

+0

Может быть, обман, но он зависит от того, что фактически хочет сделать ОП. Раджу, какая цель? Вы имеете в виду «получить копию вращающегося UIImage?» Или, возможно, «отображение изображения повернуто?» Или, возможно, «оживить вращение изображения»? Это очень неопределенные вопросы. –

+0

Это также может быть похоже на то, что он задает: http://stackoverflow.com/questions/839296/how-can-i-rotate-a-uiimageview-with-respect-to-any-point-other-than-its -center –

ответ

0

Вы можете поворачивать представление, используя CCGAffineTransform. Вы можете создать матрицу вращения, указав градусы в радианах, которые хотите повернуть, а затем установите матрицу вращения как свойство .transform вашего представления.

1
image.transform = CGAffineTransformMakeRotation(3.142); 

поворачивает ее на 180 градусов.

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) 
Смежные вопросы