2

クリックすると左右に移動するビューがあります。ビューの中心点のみを取得します。ビューをクリックすると移動するため、アンカーポイントで uiview を取得するにはどうすればよいですか。

これが私のコードです:

- (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]];
    }
}
4

2 に答える 2

1

正しく理解できれば、UIView のアンカーポイントを探しています。

最初に QuartzCore をインポートします。

#import <QuartzCore/QuartzCore.h>

ビューのアンカーポイントを使用できるようになりました。

secondView.layer.anchorPoint = touchpoint;
于 2012-08-30T10:47:28.243 に答える
0

CGPointMake(x,y) のようにアンカー ポイントを指定する必要があることに注意してください。ここで、x と y は 0 以上または 1 以下です。例えば:

CGPoint selectionAnchorPoint = CGPointMake(0.15, 0.2);
于 2013-01-04T16:43:17.877 に答える