开发者社区> 问答> 正文

关于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 2104 0
1 条回答
写回答
取消 提交回答
  • locationInView:返回的是两个触摸点中间的位置。如果你需要获取每个触摸点的位置,使用locationOfTouch:inView。

    2019-07-17 19:12:23
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
边缘程序(ER) 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载