Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

id title brief article sdk
Rotate An Image View
This recipe shows how to rotate an image on the screen using a UIImageView and a CGAffineTransform.


  1. Add a sample image to your project.
  2. In a UIViewController subclass, add class variables for a UIImage and UIImageView.
UIImage image;
UIImageView imageView;
  1. In the ViewDidLoad method create the UIImage and the UIImageView.
image = UIImage.FromFile("monkey.png");
imageView = new UIImageView(new CGRect(50,50,100,100));
imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
imageView.Image = image;
  1. Set the Transform property of the UIImageView and add it as a sub view.
imageView.Transform = CGAffineTransform.MakeRotation((float)Math.PI/4);
View.AddSubview (imageView);

Additional Information

CGAffineTransform has helper functions to return various affine transforms such as rotation, scale and translation. Setting a CGAffineTransform to the Transform property of a UIView applies the transformation matrix to the view.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.