iPhone:TabBar图像的颜色?

发布于 2024-10-24 00:48:38 字数 62 浏览 6 评论 0原文

我已向 TabBar 添加了图像(橙色),但是当我运行应用程序时图像显示为灰色! 我该如何解决这个问题? 谢谢

I have added an image(Orange color) to TabBar, but when I run application image shown gray !
How can I slove this problem ?
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铜锣湾横着走 2024-10-31 00:48:38

颜色固定为蓝色。您可以尝试编写自己的自定义选项卡栏界面,或者将一些东西组合在一起,将自定义图标放置在子类 UITabBarController 中的选项卡栏上,如下所示:

-(void)setActiveCustomOverlay
{
    if ( self.activeOverlay )
    {
            [self.activeOverlay removeFromSuperview];
    }

    NSString *imagename = [NSString stringWithFormat:@"tab_%d.png",
                                                        [self selectedIndex]];
    UIImage *img = [UIImage imageNamed:imagename];
    self.activeOverlay = [[[UIImageView alloc] initWithImage:img] autorelease];
    self.activeOverlay.frame = CGRectMake(2.0f+64.0f*[self selectedIndex],3.0f,60.0f,44.0f);

    [tabbar addSubview:activeOverlay];
    [tabbar bringSubviewToFront:activeOverlay];
}

同时执行以下操作:

  • 添加一个 UIView 属性(非原子,保留)称为 activeOverlay
  • 添加一个 tabbar 属性,并将其挂接到 IB 中的选项卡栏,
  • 每当调用 setActiveCustomOverlay 时选项卡发生变化。

这是一个丑陋的黑客行为,但却是在现有项目中最容易实现的修复方法。苹果也不会拒绝。

对于 iPad,您需要调整数字,并使用更宽的标签栏图像。

The color is fixed to blue. You could either try to write your own custom tab bar interface, or hack together something to place custom icons over the tab bar in a subclassed UITabBarController, like this:

-(void)setActiveCustomOverlay
{
    if ( self.activeOverlay )
    {
            [self.activeOverlay removeFromSuperview];
    }

    NSString *imagename = [NSString stringWithFormat:@"tab_%d.png",
                                                        [self selectedIndex]];
    UIImage *img = [UIImage imageNamed:imagename];
    self.activeOverlay = [[[UIImageView alloc] initWithImage:img] autorelease];
    self.activeOverlay.frame = CGRectMake(2.0f+64.0f*[self selectedIndex],3.0f,60.0f,44.0f);

    [tabbar addSubview:activeOverlay];
    [tabbar bringSubviewToFront:activeOverlay];
}

And also do this:

  • add a UIView property (nonatomic, retain) called activeOverlay
  • add a tabbar property and hook it to the tab bar in IB
  • call setActiveCustomOverlay whenever the tab changes.

This is an ugly hack, but the easiest fix to implement in existing projects. Apple will not reject it either.

For iPad you need to tweak the numbers, and use wider tab bar images.

放手` 2024-10-31 00:48:38

标签栏图像颜色无法更改,应始终为默认颜色。请阅读 ios 的人机界面指南以获取更多详细信息。

The tab bar image color cannot be changed, it should be always be in the default color. Do read the Human interface guidelines of ios for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文