setAnchorPoint for UIImage?

Bil*_*rim 6 iphone animation rotation uiimage

所有,

这可能是非常基本的,但我找不到适合我的答案.
足够简单 - 我想围绕端点而不是中心旋转图像.我知道我真正需要的是能够设置图像的锚点然后应用变换.

但是,我无法弄清楚如何设置图像的锚点(或者它应该是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.***
Run Code Online (Sandbox Code Playgroud)

这让我发疯,所以请帮忙!:)

谢谢!

:BP:

Vla*_*mir 10

layer是imageView属性,因此以下行应该是正确的:

imgv.layer.anchorPoint = CGPointMake(0.5, 1.0);
Run Code Online (Sandbox Code Playgroud)

您收到此错误的原因可能是您需要导入quartzcore标头:

#import <QuartzCore/QuartzCore.h>
Run Code Online (Sandbox Code Playgroud)