iOS 8 UITabBar selectionIndicatorImage留下圆角矩形

时间:2023-02-10 00:00:02

I am creating a sample "Tabbed Application project" with Xcode 6.3. The tab bar is configured in the Storyboard view, and its configuration is set thus:

我正在使用Xcode 6.3创建一个示例“选项卡式应用程序项目”。标签栏在Storyboard视图中配置,其配置如下:

iOS 8 UITabBar selectionIndicatorImage留下圆角矩形

As you can see, the Selection part is set to an empty string, which is the default value.

如您所见,Selection部分设置为空字符串,这是默认值。

However, when running the app in the simulator, the tab bar looks like this:

但是,在模拟器中运行应用程序时,标签栏如下所示:

iOS 8 UITabBar selectionIndicatorImage留下圆角矩形

There is this weird semi-transparent blue rectangular background around the selected item. So what I tried is setting the selection item to the string literal "foobar," which does not exist in my project. This yields the result I was looking for:

所选项目周围有这种奇怪的半透明蓝色矩形背景。所以我尝试将选择项设置为字符串文字“foobar”,这在我的项目中是不存在的。这产生了我正在寻找的结果:

iOS 8 UITabBar selectionIndicatorImage留下圆角矩形iOS 8 UITabBar selectionIndicatorImage留下圆角矩形

The weird blue background is gone. And yet, I don't think this is the preferred way of doing this, and it might (definitely will) confuse future developers. So how should it be done?

奇怪的蓝色背景消失了。然而,我不认为这是这样做的首选方式,它可能(肯定会)混淆未来的开发人员。那怎么办呢?

1 个解决方案

#1


Button shapes is most likely on in Settings, under General>Accessibility.

“常规”>“辅助功能”下的“设置”中最有可能出现按钮形状。

Changing it to foobar fixes it because it sets the selected one to a tab that doesn't exist, therefore making button shape think that it is that instead of the original view controller.

将其更改为foobar会修复它,因为它将选定的一个设置为不存在的选项卡,因此使按钮形状认为它是原始视图控制器而不是原始视图控制器。

#1


Button shapes is most likely on in Settings, under General>Accessibility.

“常规”>“辅助功能”下的“设置”中最有可能出现按钮形状。

Changing it to foobar fixes it because it sets the selected one to a tab that doesn't exist, therefore making button shape think that it is that instead of the original view controller.

将其更改为foobar会修复它,因为它将选定的一个设置为不存在的选项卡,因此使按钮形状认为它是原始视图控制器而不是原始视图控制器。