转换方形图像或圆形图像很容易做...iphone:如何旋转带触摸事件的矩形图像?
但是如果一个矩形图像?
这是我想用触摸事件转换的图像。
圆心(30,236),如果我触摸屏幕
的ImageView上任何地方的箭头将改变我的接触点。
但是圆心还是一样的地方。
我尝试变换图像使用测试角度
它会变成这个样子......
如何调整图像?
另外的代码是在这里
- (void)viewDidLoad {
CGRect arrowImageRect = CGRectMake(20.0f, 20.0f, 15.0f, 220.0f);
arrow = [[UIImageView alloc] initWithFrame:arrowImageRect];
[arrow setImage:[UIImage imageNamed:@"arrow.png"]];
arrow.opaque = YES;
[self.view addSubview:arrow];
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
NSLog(@"Position X: %f \n, Y: %f",touchPoint.x,touchPoint.y);
CGAffineTransform transform = CGAffineTransformIdentity;
arrow.transform = CGAffineTransformRotate(transform, ??????);
}
的??????部分应该是最后的解决方案...
或者也许我需要调整imageview的大小?
感谢您的任何答复或答复:-)
韦伯
热水使用angleInRadians? –
只要使用它而不是你的'?????'在上面的代码中,这就是CGAffineTransformRotate的第二个参数所期望的那样(阅读文档;)) – AliSoftware
好的,谢谢......但结果是不正确的... 让我首先阅读文档 –