setAnchorPoint的UIImage的? [英] setAnchorPoint for UIImage?

查看:114
本文介绍了setAnchorPoint的UIImage的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,

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

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.

我不能,但是,弄清楚如何设置图像定位点(或者它应该是一个UIImageView的?)

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! :)

感谢您!

:BP:

推荐答案

层是ImageView的属性,因此下面的行应该是正确的:

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

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

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

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

#import <QuartzCore/QuartzCore.h>

这篇关于setAnchorPoint的UIImage的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆