How can I rotate UIImageView in Interface Builder?

Is it possible to rotate UIImageView in Interface Builder from Xcode? How can I do this in Photoshop, where I can scale and rotate the image.

I know that this is possible by code, but is there a way to do this in the interface builder?

+6
source share
4 answers

You cannot do this in the current version of Xcode. You can send an Apple feature request at http://radar.apple.com

However, if you want to do this, you will need to write code

#define RADIANS(degrees) ((degrees * M_PI) / 180.0) theView.transform = CGAffineTransformRotate(theView.transform, radians) 
+6
source

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

rotation

+17
source

Yes, you can use a little trick.

In your code, declare 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 the run "rotation" parameter directly on the interface builder, as it is on any UIView that you like.

enter image description here

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

+5
source

No, this is not possible in the interface builder, but the code is pretty simple:

 #define RADIANS(degrees) ((degrees * M_PI) / 180.0) CGAffineTransform rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(120.0)); imageView.transform = rotateTransform; 
+3
source

All Articles