我有一个 View ,当我点击它时,它会左右移动。我只得到 View 的点中心。我怎样才能在 anchor 上获得 uiview,因为无论我在哪里点击 View ,它都会移动。
这是我的代码:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesMoved called");
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchpoint=[touch locationInView:self.view];
if ([touch view]==secondView)
{
secondView.center=touchpoint;
[self animateFirstPoint:[touch view]];
}
}
最佳答案
如果我没看错,您正在搜索 UIView 的定位点。
首先导入QuartzCore:
#import <QuartzCore/QuartzCore.h>
现在您可以使用 View 的 anchor 了:
secondView.layer.anchorPoint = touchpoint;
关于ios - uiview touch move 获取uiview上的 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11578776/