use*_*169 4 uinavigationcontroller ios uiswipegesturerecognizer uipangesturerecognizer ios7
I want to make a back swipe like the one in iOS 7.I'm still new with the whole iOS development, this is what I'm currently using.
Currently I have a pan gesture that detects if the user swipes back and then it just pops the navigation controller.
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.view addGestureRecognizer:pan];
-(void)handlePan:(UIPanGestureRecognizer *)sender{
CGPoint tran = [recognizer translationInView:recognizer.view];
CGPoint vel = [recognizer velocityInView:recognizer.view];
if(vel.x > 500 && tran.x > 100){
[self.navigationController popViewControllerAnimated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
I want the previous view to follow the finger on the pan gesture instead of just calling the pop to root. For example,
小智 9
这将需要一个自定义容器视图控制器.简单来说,你有一个视图控制器,它可以容纳2个视图控制器(左边是视图1,右边是视图2).
将平移手势附加到容器视图,当用户移动时,您可以为每个子视图控制器计算适当的帧.例如,如果用户向右平移,则将视图2向右移动,并从左侧显示视图1(根据需要调用子视图控制器方法).
手势完成后,您应该检查最终位置以及平移的最终方向,以决定放置视图控制器的位置.例如,如果您在屏幕上的视图1的90%右侧完成平移,则应在屏幕上完全移动视图1并在屏幕上查看2.如果你用50%的每个完成,你应该使用平移的方向来决定哪个视图将保留在屏幕上.
归档时间: |
|
查看次数: |
3888 次 |
最近记录: |