SetAnchorPoint for UIImage?

All,

It is probably very simple, but I cannot find an answer that works for me.
Simple enough - I want to rotate the image around the end point, not the center. I know that all I really need is to set the anchor point of the image and then apply the transform.

I cannot, however, figure out how to set the anchor point of the image (or should it be a UIImageView?)

UIImageView * imgv = nil;
UIImage * image;

imgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"greenbar.png"]];
image = [imgv image];
image.layer.anchorPoint =  CGPointMake(0.5, 1.0);***-- Request for member 'layer' in something not a structure or union.***
imgv.image.layer.anchorPoint = CGPointMake(0.5, 1.0); ***-- Request for member 'layer' in something not a structure or union.***
imgv.layer.anchorPoint = CGPointMake(0.5, 1.0);  ***-- Accessing unknown 'anchorPoint' component of a property.***

It drives me crazy, so please help! :)

Thank!

: bp:

+5
source share
1 answer

layer is an imageView property, so the following line should be correct:

imgv.layer.anchorPoint = CGPointMake(0.5, 1.0);

, , , quartzcore:

#import <QuartzCore/QuartzCore.h>
+8

All Articles