我有一张图片,并使用GestureRecognizer进行转换。
func imagePinView(sender:UIPinchGestureRecognizer){
currentEditImage.transform = CGAffineTransformScale(currentEditImage.transform, sender.scale, sender.scale)
sender.scale = 1.0
}
func imageRotateView(sender:UIRotationGestureRecognizer){
let currentTrans = currentEditImage.transform
currentEditImage.transform = CGAffineTransformRotate(currentTrans, sender.rotation)
sender.rotation = 0.0
}
func imageDragView(sender:UIPanGestureRecognizer){
self.popUpEditView.bringSubviewToFront(sender.view!)
let translation = sender.translationInView(self.popUpEditView)
currentEditImage.center = CGPointMake(currentEditImage.center.x + translation.x, currentEditImage.center.y + translation.y)
sender.setTranslation(CGPointZero, inView: self.popUpEditView)
}
但是当我裁剪图像时。它不起作用。这是我的代码:
let imageRef = CGImageCreateWithImageInRect(curImage?.CGImage, rectToCrop)
let croppedImage:UIImage = UIImage(CGImage: (curImage?.CGImage)!, scale: 0, orientation: currentEditImage.image!.imageOrientation)