I'm developing an iOS app for iPad. Is there any way to rotate a UIImage 90º and then add it to a UIImageView? I've tried a lot of different codes but none worked...
Thanks!
You may rotate UIImageView itself with: UIImageView *iv = [[UIImageView alloc] initWithImage:image]; iv. transform = CGAffineTransformMakeRotation(M_PI_2); Or if you really want to change image, you may use code from this answer, it works.
Step 1 − Open Xcode→SingleViewApplication→name it RotateImage. Step 2 − Open Main. storyboard, add UIImageView and add 2 buttons as shown below name them ROTATE BY 90 DEGREES AND ROTATE BY 45 DEGREES. Add some sample images to UIImage View.
Go to the ViewController. swift file and implement the rotateImage method. The image will rotate 180 degrees using the CGAffineTranform function. Build and Run the project and tap the Rotate Button to rotate the image.
You may rotate UIImageView
itself with:
UIImageView *iv = [[UIImageView alloc] initWithImage:image];
iv.transform = CGAffineTransformMakeRotation(M_PI_2);
Or if you really want to change image, you may use code from this answer, it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With