当用户用两根手指向上滑动时,我想更改导航栏色调颜色。我需要在App Delegate中执行此操作,以便我可以普遍更改所有导航栏色调颜色。我可以做一个手势,但我不确定如何实际调用一个动作。谢谢你的帮助:D
答案 0 :(得分:1)
您是否尝试过写作:
[self.navController.view addGestureRecognizer:yourGestureInstanceHere];
此处yourGestureInstanceHere
表示点击次数为2的滑动手势。
另外,我建议子类你的UINavigationController并在那里写这个功能,而不是AppDelegate。 AppDelegate
不是处理这些功能的类。
修改强>
-(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
}