Mahavir Mahavir - 1 year ago 90
iOS Question

IOS - How to rotate image at some degree

I want to rotate image with some angle as show in the below image.

enter image description here

I am trying to with that

CGAffineTransform t = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
imageView.transform = t;

I am not getting output like this. even I am not close with this.

Answer Source

Here is the code I used to rotate an image by 30 degrees

 UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 20, 320, 400)];
    imgView.image = [UIImage imageNamed:@"maxresdefault.jpg"];
    [self.view addSubview:imgView];
float degrees = 30.0f;
    float radians = (degrees* M_PI/180);
    imgView.layer.transform = CATransform3DMakeRotation(radians, 0, 0, 1.0);

The Simulator ScreenShot before transform

enter image description here

Here is the Simulator ScreenShot after Transform

enter image description here

Hope this helps you out.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download