             return self.imageCropRect
         }
     }
-    var rotationAngle: CGFloat!
+    var rotationAngle: CGFloat! {
+        get {
+            let rotation = self.imageView!.transform
+            return CGFloat(atan2f(Float(rotation.b), Float(rotation.a)))
+        }
+        set {
+            self.imageView!.transform = CGAffineTransformMakeRotation(rotationAngle)
+        }
+    }
     var rotationGestureRecognizer: UIRotationGestureRecognizer!
     
     private let MarginTop: CGFloat = 37.0

            return self.image?.rotatedImageWithtransform(self.rotation, rect: self.zoomedCropRect)
        }
    }
    var zoomedCropRect: CGRec
    var rotation: CGAffineTransform!
    var userHasModifiedCropArea: Bool!
    var keepingCropAspectRatio: Bool! {
        set {
            self.cropRectView.keepAspectRatio = self.keepingCropAspectRatio

        cropRect.size = CGSizeMake(width, height);
        self.zoomToCropRect(cropRect, center: center)
    }
    
    private func cappedCropRectInImageRectWithCropRectView(cropRectView: SSCropRectView) -> CGRect {
        
        let cropRect = cropRectView.frame
        
        let rect = self.convertRect(cropRect, toView: self.scrollView)
        if (CGRectGetMinX(rect) < CGRectGetMinX(self.zoomingView.frame)) {
            cropRect.origin.x = CGRectGetMinX([self.scrollView convertRect:self.zoomingView.frame toView:self]);
            CGFloat cappedWidth = CGRectGetMaxX(rect);
            cropRect.size = CGSizeMake(cappedWidth,
                !self.keepingCropAspectRatio ? cropRect.size.height : cropRect.size.height * (cappedWidth/cropRect.size.width));
        }
        if (CGRectGetMinY(rect) < CGRectGetMinY(self.zoomingView.frame)) {
            cropRect.origin.y = CGRectGetMinY([self.scrollView convertRect:self.zoomingView.frame toView:self]);
            CGFloat cappedHeight =  CGRectGetMaxY(rect);
            cropRect.size = CGSizeMake(!self.keepingCropAspectRatio ? cropRect.size.width : cropRect.size.width * (cappedHeight / cropRect.size.height),
                cappedHeight);
        }
        if (CGRectGetMaxX(rect) > CGRectGetMaxX(self.zoomingView.frame)) {
            CGFloat cappedWidth = CGRectGetMaxX([self.scrollView convertRect:self.zoomingView.frame toView:self]) - CGRectGetMinX(cropRect);
            cropRect.size = CGSizeMake(cappedWidth,
                !self.keepingCropAspectRatio ? cropRect.size.height : cropRect.size.height * (cappedWidth/cropRect.size.width));
        }
        if (CGRectGetMaxY(rect) > CGRectGetMaxY(self.zoomingView.frame)) {
            CGFloat cappedHeight =  CGRectGetMaxY([self.scrollView convertRect:self.zoomingView.frame toView:self]) - CGRectGetMinY(cropRect);
            cropRect.size = CGSizeMake(!self.keepingCropAspectRatio ? cropRect.size.width : cropRect.size.width * (cappedHeight / cropRect.size.height),
                cappedHeight);
        }
        
        return cropRect
    }
}
