全部,

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

但是,我无法弄清楚如何设置图像的 anchor (或者应该是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.***

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

谢谢!

:bp:

最佳答案

图层是imageView属性,因此以下行应正确:

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

出现此错误的原因可能是您需要导入quartzcore header :
#import <QuartzCore/QuartzCore.h>

10-06 09:32