纵观苹果的文档倒是例如,有以下方法:锚定点的CALayer
// scale and rotation transforms are applied relative to the layer's anchor point
// this method moves a gesture recognizer's view's anchor point between the user's fingers
- (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
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;
}
}
第一个问题,有人可以解释设置在子视图的定位点,并改变中心的逻辑superview(就像为什么这样做了)?
最后,数学如何为anchorPoint语句工作?如果你有一个界限为500,500的视图,并且说你用一个手指触摸100,100,用另一个手指触摸500,500。在此框中,您的正常锚点是(250,250)。现在呢? (没有线索)
谢谢!
@水晶做了这个帮助吗? – 2011-06-19 18:04:46