自定义动画navigationItem [英] Custom navigationItem animation
问题描述
我要上leftBarButtonItem自定义动画:
的UIBarButtonItem *菜单按钮= [[的UIBarButtonItem页头]
initWithTitle:@菜单
风格:UIBarButtonItemStyleBordered
目标:自我
动作:@selector(onMenuButtonTouch)];
viewController.navigationItem.leftBarButtonItem =菜单按钮;
我的UINavigationController推动和持久性有机污染物的观点与自定义动画所以leftBarButtonItem没有目前的动画。
[self.navigationController pushViewController:myViewController动画:NO];
[UIView的animateWithDuration:...
-
首先,我更改的属性,如果它是动画,但没有工作的看到。然后我试图动画开始前设置的属性,但没有任何工作。这需要绝对没有影响。
有没有办法动画这样的事情,例如?
self.navigationController.navigationItem.leftBarButtonItem.width = 10;
或
self.navigationController.navigationItem.leftBarButtonItem.customView.alpha = 0;
的UIBarButtonItem
是不是一个子类的UIView
所以你不能对他们,但 customView
是的UIView
对象,这样你就可以制作动画。应用动画p>
[UIView的animateWithDuration:1.0
动画:^ {
self.navigationItem.rightBarButtonItem.customView.alpha = 0;
}];
I want a custom animation on the leftBarButtonItem:
UIBarButtonItem *menuButton = [[UIBarButtonItem alloc]
initWithTitle:@"Menu"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(onMenuButtonTouch)];
viewController.navigationItem.leftBarButtonItem = menuButton;
My UINavigationController pushes and pops views with a custom animation so the leftBarButtonItem doesn't have any animations at the moment.
[self.navigationController pushViewController:myViewController animated:NO];
[UIView animateWithDuration:...
-
First I changed a property the see if it is animated but that didn't work. Then I tried to set the property before the animation starts but that didn't work either. It takes absolutely no effect.
Is there a way to animate something like this for example?
self.navigationController.navigationItem.leftBarButtonItem.width = 10;
or
self.navigationController.navigationItem.leftBarButtonItem.customView.alpha = 0;
UIBarButtonItem
s are not a subclass of UIView
so you can't apply animations on them but customView
is a UIView
object so you can animate it.
[UIView animateWithDuration:1.0
animations:^{
self.navigationItem.rightBarButtonItem.customView.alpha = 0;
}];
这篇关于自定义动画navigationItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!