문제

I want to change the Navigation Bar Tint Colour when the user swipes up with 2 fingers. I need to do this in the App Delegate so that I can universally change all the nav bar tint colours. I can call a gesture but I'm not sure how to actually get an action called. Thanks for the help :D

도움이 되었습니까?

해결책

Have you try writing like:

[self.navController.view addGestureRecognizer:yourGestureInstanceHere];

Here yourGestureInstanceHere represents a swipe gesture with number of taps as 2.

Also, I would suggest to sub class your UINavigationController and write this functionality there, instead of AppDelegate. AppDelegate is not the class to handle these functionalities.

EDIT

-(void)addGestureToNavigationController

    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeRight:)];

    [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];

     swipeRight.numberOfTouchesRequired = 2;

    [swipeRight setDelegate:self];

    [self.navigationController.view addGestureRecognizer:swipeRight];

}

// Selector

-(void)handleSwipeRight:(UISwipeGestureRecognizer *)recognizer

{

    // TODO : Write change tint colour logic

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top