选中后如何删除覆盖UITabBarItem的蓝色方块? [英] How can I remove the blue square that overlays UITabBarItem when selected?

查看:82
本文介绍了选中后如何删除覆盖UITabBarItem的蓝色方块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iPad应用程序(Xcode 5,iOS 7,ARC和情节提要).我有一个UITabBarController,每个场景都有一个UITabBarItem.

I have an iPad app (Xcode 5, iOS 7, ARC and Storyboards). I have a UITabBarController, and each scene has a UITabBarItem.

当我点击一个标签栏项目时,它会转到正确的场景,但是当前"标签栏项目的图像会被一个蓝色框"覆盖.

When I tap a tab bar item, it goes to the correct scene, but the "current" tab bar item image is overlaid by a "blue box".

如何用不同的图像替换该蓝色框"? (我不想更改颜色;我想用其他图像替换它.)

How can I replace that "blue box" with a different image? (I don't want to change the color; I want to replace it with a different image).

推荐答案

用于标签栏项目的图像必须具有renderingModeUIImageRenderingModeAlwaysOriginal,否则它们将显示为蓝色方块(模板).这样的文件"Tab Bars"就是这样,

The images you use for a tab bar item have to have their renderingMode be, UIImageRenderingModeAlwaysOriginal or they will appear as blue squares (templates). The document called "Tab Bars", says this,

标签栏项目图标

Tab Bar Item Icons

选项卡栏中的每个项目都可以有一个自定义的选定图像,并且未选定 图像.您可以在初始化选项卡栏项目时指定这些图像 使用initWithTitle:image:selectedImage:方法.请注意,一个标签 酒吧商品图像将自动呈现为模板图像 在标签栏中,除非您明确将其渲染模式设置为 UIImageRenderingModeAlwaysOriginal.有关更多信息,请参见模板. 图片.

Each item in a tab bar can have a custom selected image and unselected image. You can specify these images when you initialize a tab bar item using the initWithTitle:image:selectedImage: method. Note that a tab bar item image will be automatically rendered as a template image within a tab bar, unless you explicitly set its rendering mode to UIImageRenderingModeAlwaysOriginal. For more information, see Template Images.

我认为您不能在情节提要中进行设置,因此您应该在控制器的init方法中进行设置,

I don't think you can set them up in the storyboard, so you should do it in the controller's init method,

-(id)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        UIImage *img = [UIImage imageNamed:@"pic.jpg"];
        img  = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.tabBarItem setSelectedImage:img];
    }
    return self;
}

这篇关于选中后如何删除覆盖UITabBarItem的蓝色方块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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