views:

1341

answers:

1

I don't really understand what this function is good for. Can someone explain that (maybe with some examples)?

Can I rotate an UIImageView object with this one?

+1  A: 

CGAffineTransformMakeRotation is a constructor that creates you a rotation matrix, like CGPointMake, or NSMakePoint. Some functions requires you to pass in a transformation matrix like:

 
void CGPathAddArc (
   CGMutablePathRef path,
   const CGAffineTransform *m,
   CGFloat x,
   CGFloat y,
   CGFloat radius,
   CGFloat startAngle,
   CGFloat endAngle,
   bool clockwise
);

You can use UIGraphicsGetCurrentContext to get a CGContextRef and transform/rotate the context as you like.

UPDATE: You can directly change UIView's transform. It is a property:
@property(nonatomic) CGAffineTransform transform.
Thanks to Brad for pointing this out.

phi
Actually, you can directly rotate a UIView using the CGAffineTransform struct produced by CGAffineTransformMakeRotation(). You just set the UIView's transform property to the new CGAffineTransform and it will be rotated.
Brad Larson
Brad is right. I overlooked the documentation.
phi