2012-07-20 2 views
2

나는 그것을 클릭하면 왼쪽과 오른쪽으로 이동하는보기가 있습니다. 나는보기의 중심점 만 얻는다. 앵커 포인트에 uiview를 가져 오는 방법은 어디에서 움직일지를 클릭하기 때문입니다. 내가 할 경우uiview touch move uview에 앵커 포인트 가져 오기

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

답변

1

당신이 바로 당신이있는 UIView의 anchorpoint 검색하는 :

여기 내 코드입니다.

먼저 수입 QuartzCore :

secondView.layer.anchorPoint = touchpoint; 
0

것은 당신이 CGPointMake (x, y)는 x와 같은 앵커 포인트를 지정해야 기억

#import <QuartzCore/QuartzCore.h> 

지금 당신은 당신의보기의 anchorpoint을 사용할 수 있습니다 y는 0보다 크거나 같거나 1과 같고; 예 :

CGPoint selectionAnchorPoint = CGPointMake(0.15, 0.2); 
관련 문제