I have one uiimageview which is added as subview in uiview. frame for uiimageview is uiview's bounds. I am using this uiview just to show the border. Now when i rotate the imageview, only image view is rotated, but while rotating extra part beyond uiview is getting clipped. How can i resize uiview along with image views rotation.
This is my code. I have done what you have said but view is not resizing
- (void)handleRotate:(UIRotationGestureRecognizer *)recognizer {
float rotation = angle + -recognizer.rotation;
recognizer.view.transform = CGAffineTransformMakeRotation(-rotation);
if (recognizer.state == UIGestureRecognizerStateEnded) {
angle = rotation;
}
CGFloat diagonal = sqrt( recognizer.view.bounds.size.width*recognizer.view.bounds.size.width + recognizer.view.bounds.size.height*recognizer.view.bounds.size.height );
CGRect rect = view.frame;
rect.origin.x -= ((rect.size.width-diagonal)/2);
rect.origin.y -= ((rect.size.height-diagonal)/2);
rect.size.width = diagonal;
rect.size.height = diagonal;
view.frame = rect;
}