UIImage 的 setAnchorPoint?
所有,
这可能是非常基本的,但我找不到适合我的答案。
足够简单——我想围绕端点而不是中心旋转图像。我知道我真正需要的是能够设置图像的锚点,然后应用变换。
然而,我无法弄清楚如何设置图像的锚点(或者它应该是 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:
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:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
图层是 imageView 属性,因此以下行应该是正确的:
出现此错误的原因可能是您需要导入quartzcore标头:
layer is imageView property so the following line should be correct:
The reason you get this error may be that you need to import quartzcore header: