1

你好

如何从touches获取 x&y 值开始到我们的方法,我制作了这样的示例来获取我的 TextField 的位置,并且这个位置是在另一种方法中获取的,以计算文本的位置并将文本添加到 UIImage ,我在最后阶段面临问题,将此参数传递给CGContextShowTextAtPoint,这是我的代码。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
 UITouch *touch = [touches anyObject];
 NSUInteger tapCount = [touch tapCount];
 CGPoint location = [touch locationInView:touch.view];
 textBox.center = location; 
 NSLog(@"location-%f,%f", location.x,location.y);

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
 NSLog(@"touches moved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
 NSLog(@"touches ended");
}

我需要将 location.x,location.y 的值传递给另一种方法。这样我就可以修复文本的位置,有人可以帮我吗...

提前致谢

4

0 回答 0