Width and height increase after CGAffineTransformRotate applied to a UIView Width and height increase after CGAffineTransformRotate applied to a UIView objective-c objective-c

Width and height increase after CGAffineTransformRotate applied to a UIView


The width and height (presumably you are taking this from frame.size) have to change because they describing the smallest rectangle that holds the entire rotated view - if you rotate a rectangle by 45 degrees, then the rectangle to hold the rotated rectangle is wider and taller than the original rectangle.

The "real" size of your rotated view will still be available in the bounds rectangle - this is expressed in the view's internal coordinate system which is not rotated.

So, if your original frame was origin (100,100), size (100,50), your rotated view would have a frame where the origin and size was a rectangle that could fit your rotated view within it, described in the superview's coordinate system. If you now did this:

CGFloat width = contentView.frame.size.width;

You would get your changed value. However, if you did this:

CGFloat width = contentView.bounds.size.width;

You would get your original 100 width value.