How can I rotate an UIImageView in Interface Builder?

Yes, you can do this in interface builder without any additional code with layer.transform.rotation.z runtime attribute. Note that this value is in radians.

rotation


Yes you can but using a little trick.

Declare in your code a new UIView Category like this

@interface UIView (IBRotateView)

@property (nonatomic, assign) CGFloat rotation;

@end


@implementation UIView (IBRotateView)
@dynamic rotation;

- (void)setRotation:(CGFloat)deg
{
    CGFloat rad = M_PI * deg / 180.0;

    CGAffineTransform rot = CGAffineTransformMakeRotation(rad);

    [self setTransform:rot];
}

@end

Now you can use a runtime parameter "rotation" directly on interface builder like this on any UIView you like.

enter image description here

Obviously interface builder will not rotate the view in its internal render because it will only effect the runtime rendering.


You can't do this in the current version of Xcode. You may submit a feature request to Apple at https://feedbackassistant.apple.com/

However if you want to do it, you will need to write some code

#define RADIANS(degrees) ((degrees * M_PI) / 180.0)

theView.transform = CGAffineTransformRotate(theView.transform, radians)