在iphone的uinavigationbar上使用图像或色调? [英] using image or tint color on uinavigationbar in iphone?

查看:111
本文介绍了在iphone的uinavigationbar上使用图像或色调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在导航栏上显示背景图像或为本机iphone应用程序中的导航栏添加色调?

how do i show a background image on a navigation bar or give tint color to the navigation bar in a native iphone application??

推荐答案

一周前正在寻找这个。在这里讨论发现了这个。苹果。 com / thread.jspa?threadID = 1649012& tstart = 0(抱歉不允许我发布真实链接)。

Was looking for this a week ago. Found this over here discussions. apple. com/thread.jspa?threadID=1649012&tstart=0 (sorry won't let me post a real link).

-(void)setBackgroundImage:(UIImage*)image withTag:(NSInteger)bgTag{
if(image == NULL){ //might be called with NULL argument
    return;
}
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];
aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
aTabBarBackground.tag = bgTag;
[self addSubview:aTabBarBackground];
[self sendSubviewToBack:aTabBarBackground];
[aTabBarBackground release];
}
/* input: The tag you chose to identify the view */
-(void)resetBackground:(NSInteger)bgTag {
    [self sendSubviewToBack:[self viewWithTag:bgTag]];
}

我将此作为UINavigationBar的类别。要在UINavigationBarController中为UINavigationBar设置背景图像,我这样做了:

I made this as a category to UINavigationBar. To set it a background image for a UINavigationBar inside a UINavigationBarController, I did this:

[navigationControllerForChannels.navigationBar setBackgroundImage:[UIImage imageNamed:@"top_bar.png"] withTag:48151623];

我在更新标签栏时遇到了一些问题,所以你要打电话

I've had some buginess when updating the tab bar, so you'll want to call

[self.navigationController.navigationBar resetBackground:48151623];

对酒吧进行任何修改后。

After any modifications to the bar.

这篇关于在iphone的uinavigationbar上使用图像或色调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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