开发者社区 问答 正文

关于multi touches:多手势操作时anchorpoint的计算问题

ios代码中添加一个旋转的收拾识别UIRotationGestureRecognizer功能,在对应的target方法中如果加入一下代码:

if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
    UIView *piece = gestureRecognizer.view;
    CGPoint locationInView = [gestureRecognizer locationInView:piece];
    CGPoint locationInSuperview = [gestureRecognizer locationInView:piece.superview];

    piece.layer.anchorPoint = CGPointMake(locationInView.x / piece.bounds.size.width, locationInView.y / piece.bounds.size.height);
    piece.center = locationInSuperview;
}

请问这里的locationInView是指的哪个值,因为这里应该是有两个手指touch屏幕。

展开
收起
爵霸 2016-03-24 11:19:36 2153 分享 版权
1 条回答
写回答
取消 提交回答
  • locationInView:返回的是两个触摸点中间的位置。如果你需要获取每个触摸点的位置,使用locationOfTouch:inView。

    2019-07-17 19:12:23
    赞同 展开评论
问答分类:
问答地址: