当前位置: 潍坊三六九 > iOS开发的一些奇巧淫技

iOS开发的一些奇巧淫技

内容

self.navigationItem.leftBarButtonItem=[[UIBarButtonItemalloc] initWithImage:img style:UIBarButtonItemStylePlain target:self action:@selector(onBack:)]; self.navigationController.interactivePopGestureRecognizer.delegate=(id<UIGestureRecognizerDelegate>)self; -(void)pan:(UIPanGestureRecognizer*)sender { typedefNS_ENUM(NSUInteger,UIPanGestureRecognizerDirection){ UIPanGestureRecognizerDirectionUndefined, UIPanGestureRecognizerDirectionUp, UIPanGestureRecognizerDirectionDown, UIPanGestureRecognizerDirectionLeft, UIPanGestureRecognizerDirectionRight }; staticUIPanGestureRecognizerDirectiondirection=UIPanGestureRecognizerDirectionUndefined; switch(sender.state){ caseUIGestureRecognizerStateBegan:{ if(direction==UIPanGestureRecognizerDirectionUndefined){ CGPointvelocity=[sendervelocityInView:recognizer.view]; BOOLisVerticalGesture=fabs(velocity.y)>fabs(velocity.x); if(isVerticalGesture){ if(velocity.y>0){ direction=UIPanGestureRecognizerDirectionDown; }else{ direction=UIPanGestureRecognizerDirectionUp; } } else{ if(velocity.x>0){ direction=UIPanGestureRecognizerDirectionRight; }else{ direction=UIPanGestureRecognizerDirectionLeft; } } } break; } caseUIGestureRecognizerStateChanged:{ switch(direction){ caseUIPanGestureRecognizerDirectionUp:{ [selfhandleUpwardsGesture:sender]; break; } caseUIPanGestureRecognizerDirectionDown:{ [selfhandleDownwardsGesture:sender]; break; } caseUIPanGestureRecognizerDirectionLeft:{ [selfhandleLeftGesture:sender]; break; } caseUIPanGestureRecognizerDirectionRight:{ [selfhandleRightGesture:sender]; break; } default:{ break; } } break; } caseUIGestureRecognizerStateEnded:{ direction=UIPanGestureRecognizerDirectionUndefined; break; } default: break; } } -(void)navigationController:(UINavigationController*)navigationControllerwillShowViewController:(UIViewController*)viewControlleranimated:(BOOL)animated { [[UIApplicationsharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent]; }

相关推荐

推荐信息