Question

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

Was it helpful?

Solution

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

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top