iOS 7中UINavigation Back Button的自定义图像 [英] Custom image for UINavigation Back Button in iOS 7

查看:106
本文介绍了iOS 7中UINavigation Back Button的自定义图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义 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 7中显示我的后退按钮,就像在iOS 6中一样?请帮帮忙?

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)];

这是Apple开发中心的原始帖子讨论论坛

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 Back Button的自定义图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆