iOS 7 中 UINavigation 后退按钮的自定义图像 [英] Custom image for UINavigation Back Button in iOS 7
问题描述
我有一个自定义的 UIBarButtonItem
,其图像在 iOS 6.1 中运行良好.但是 iOS 7 有一个 tintColor
并且它在我的图像上覆盖了这个颜色.如果我将 tintColor
设置为 [UIColor clearColor]
按钮不会一起显示.
I have a custom UIBarButtonItem
with an image that works fine in iOS 6.1. But iOS 7 has a tintColor
and it overlays this color over my image. If I set the tintColor
to [UIColor clearColor]
the button doesn't show up all together.
如何让我的后退按钮像在 iOS 6 中一样在 iOS 7 中显示?请帮忙?
How can I have my back button show up in iOS 7 as it does in iOS 6? Please help?
推荐答案
尝试在 ios7 中这样设置 UIBarButtonItem
:-
Try to set UIBarButtonItem
like this way in ios7:-
UIImage *temp = [[UIImage imageNamed:@"theImage"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage:temp style:UIBarButtonItemStyleBordered target:self action:@selector(action)];
这是苹果开发中心的原创帖子讨论论坛
Here is an original post in apple Dev center discussion Forums
要同时支持 iOS7 和更低版本,请检查 system-version
并设置如下代码:-
For supporting both version iOS7 as well as lower then you check system-version
and set code like:-
UIImage *temp=nil;
if([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
{
temp = [UIImage imageNamed:@"btn-back.png"];
}
else
{
temp = [[UIImage imageNamed:@"btn-back.png"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
}
这篇关于iOS 7 中 UINavigation 后退按钮的自定义图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!