沿 y 轴移动 UIImageView
我正在开发一个应用程序,我只想在 Y 轴上移动 UIImage,而不是在 X 轴上,这就是我到目前为止所做的
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { stretchPoint = [[touches anyObject]locationInView:self.view]; arrowImage.center = stretchPoint; }
上面的代码在两个轴上移动 arrowImage, stretchPoint 是 CGPoint 的一个实例,我的应用程序处于纵向模式,任何人都可以给我一个如何执行此操作的基本想法,因为 arrowImage 是 UIImageView 的实例。
I am working on a app and i want to move a UIImage in the Y axis only, not in Xaxis, here's what i did till now
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { stretchPoint = [[touches anyObject]locationInView:self.view]; arrowImage.center = stretchPoint; }
The above code is moving the arrowImage in both the axis,
stretchPoint is an instance of CGPoint, My app is in portrait mode, can anyone give me a basic idea to how to do this, as the arrowImage is a instance of UIImageView.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这应该可以正常工作:
this should work fine:
子类化 UIImage 并实现以下代码
Subclass the UIImage and implement the following code
我不确定因为没有测试过,但你可以实现这样的东西:
I am not sure as have not tested,but you can implement something like this :
像这样的东西:
Something like: