******controller.h
//******************************************************//
IBOutlet UIView *menuView;
//******************************************************//
******controller.m
//******************************************************//
- (void)viewDidLoad
{
UIPanGestureRecognizer* drg = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(dragGesutreMethod:)];//내가 만든 함수
[menuView addGestureRecognizer:drg];//이동 시킬 뷰에 제스쳐 함수 추가
[drg release];
....
}
-(IBAction)dragGesutreMethod:(UIGestureRecognizer*)sender
{
CGPoint touchedpt = [sender locationInView:self.menuView];//menuview내에서 클릭된 좌표
startPt = touchedpt;
if (movingPt.x < 60 || movingPt.x > -60 ) {
if (startPt.x < 150) {
NSLog(@"moving to right, touch point is %d",startPt.x);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
CGAffineTransform transform = CGAffineTransformMakeTranslation(endPt.x, 0.0);
[[self menuView] setTransform:transform];
if(movingPt.x < 20)
movingPt.x += 3;
CGAffineTransform transform2 = CGAffineTransformMakeTranslation(movingPt.x, 0.0);
[[self menuView] setTransform:transform2];
[UIView commitAnimations];
} else {
NSLog(@"moving to left touch point is %f, pt point is %d",startPt.x);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
CGAffineTransform transform = CGAffineTransformMakeTranslation(endPt.x, 0.0); [[self menuView] setTransform:transform];
if(movingPt.x> -20)
movingPt.x -= 3;
CGAffineTransform transform2 = CGAffineTransformMakeTranslation(movingPt.x, 0.0);
[[self menuView] setTransform:transform2];
[UIView commitAnimations];
}
endPt.x = movingPt.x;
}
}
'ios aos 개발 > iPhone' 카테고리의 다른 글
[iPhone] 빙글빙글 효과 만들기 & 알림창(UIAlertView) 사라지게 하기 (0) | 2011.08.24 |
---|---|
[iPhone] 동기식 다운로드 download (0) | 2011.07.22 |
[iPhone] 어플 실행시 navigation barbutton 만들기 (0) | 2011.07.03 |
[iPhone] UITableVIew 꼭 써야하는 함수 (0) | 2011.07.02 |
[iPhone] UIAlertView 창 띄우기, 사라지게 하기 (0) | 2011.06.18 |