UIImage 的 setAnchorPoint?

发布于 2024-10-07 13:30:59 字数 735 浏览 3 评论 0原文

所有,

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

然而,我无法弄清楚如何设置图像的锚点(或者它应该是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

貪欢 2024-10-14 13:30:59

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

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

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

#import <QuartzCore/QuartzCore.h>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文