Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setAnchorPoint for UIImage?

All,

This is probably very basic, but I cannot find an answer that works for me.
Simple enough -- I want to rotate an image around an endpoint, not the center. I know that all I really need is to be able 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 an 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.***

This is driving me crazy, so please help! :)

Thank you!

:bp:

like image 648
Billy Pilgrim Avatar asked Dec 14 '10 17:12

Billy Pilgrim


1 Answers

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

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

The reason you get this error may be that you need to import quartzcore header:

#import <QuartzCore/QuartzCore.h>
like image 112
Vladimir Avatar answered Sep 18 '22 13:09

Vladimir