避免 UIBarButtonItem 在 PushViewController 动画期间淡出/淡入
我在我的only-ios5应用程序中有一个navigationControllerDelegate:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"common-settingsbutton"] style:UIBarButtonItemStylePlain target:nil action:nil];
[viewController.navigationItem setRightBarButtonItem:myButton];
}
它可以工作,但是当发生具有默认动画的推送视图控制器时(即使用“推送segue”),rightBarButtonItem在动画期间淡出和淡入。
我怎样才能避免这种情况?
更新
我发现的唯一解决方法是:
使用以 png 绘制的相同 UIBarButtonItems 创建 UINavigationBar 背景 (相同位置,相同颜色),并根据我需要的按钮正确设置背景。 然后,当然,添加您的 UIBarButtonItems。
I have in my only-ios5 application a navigationControllerDelegate:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"common-settingsbutton"] style:UIBarButtonItemStylePlain target:nil action:nil];
[viewController.navigationItem setRightBarButtonItem:myButton];
}
It works, but when a push view controller with default animation occurs (i.e. using a "push segue") the rightBarButtonItem fadeout and fadein during animation.
How can I avoid this?
UPDATE
The only workaround I found is:
create UINavigationBar background with same UIBarButtonItems drawn in png (in the same position, same color) and set background correctly based on buttons I need.
Then, of course, add your UIBarButtonItems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我发现的唯一解决方法是:
使用以 png 绘制的相同 UIBarButtonItems 创建 UINavigationBar 背景(相同位置,相同颜色),并根据我需要的按钮正确设置背景。然后,当然,添加您的 UIBarButtonItems。
The only workaround I found is:
create UINavigationBar background with same UIBarButtonItems drawn in png (in the same position, same color) and set background correctly based on buttons I need. Then, of course, add your UIBarButtonItems.
在推入视图控制器而不是协议方法之前创建按钮。
Create button before pushing in the view controller instead of in protocol method.
根据文档,您可以禁用 BarButtonItem 的动画
但这似乎在故事板项目中不起作用。该按钮仍然有动画效果。
According to the docs you can disable the animation for a BarButtonItem
But this does not seem to work in a storyboarded project. The button still animates in.
当您单击 rightBarButton 时,它会突出显示,如淡入/淡出。为了避免该按钮的一个属性 adjustmentImageWhenHighlighted 设置为 NO。
When u click on rightBarButton its highlighted like Fade In/ Fade Out. To avoid that one property of that button adjustsImageWhenHighlighted is set to NO.