【发布时间】:2016-09-18 01:54:50
【问题描述】:
我们正在开发一个使用 react-native 的 iOS 应用程序。在这个应用程序中,我们使用了TabBarIOS 组件。我们有五个选项卡,其中活动选项卡具有单独的图标,我们的图像布局如下:
|_images
|__tabbaricons
|___ tab-1-on.png (35x35)
|___ tab-1-on@2.png (70x70)
|___ tab-1-on@3.png (105x105)
|___ tab-1-off.png (35x35)
|___ tab-1-off@2.png (70x70)
|___ tab-1-off@3.png (105x105)
在 TabBarIOS 组件中,我将 Items decared 如下:
<TabBarIOS.Item
selected={currentTab.name === 'profile'}
icon={require('./images/tabbaricons/profile-off.png')}
selectedIcon={require('./images/tabbaricons/profile-on.png')}
renderAsOriginal={true}
title=""
onPress={() => {
this.props.navigation.gotoTab({
tabInformation: { name: 'profile', content: '' },
statusBarStyle: 'light-content'
})
}}>
<Profile navigator={this.props.navigator} navigation={this.props.navigation />
</TabBarIOS.Item>
在 iPhone4s、iPhone5 和 iPhone6s+ 中,图标都是低质量的,如果不选择它们也会被灰色覆盖,这完全破坏了图像。选择后,它们被蓝色默认色调覆盖。我尝试将色调颜色设置为transparent,但这使得选项卡图标在其处于活动状态时不可见。
这种着色完全让我们退缩了,因为在标签栏中设置图标是我们推迟到最后的事情之一,因为它应该过于简单。事实证明这是更大的麻烦之一。
之前我们使用 UIWebView 并将 512x512 的图像缩小到一定尺寸以提高清晰度。我无法判断这些较小的图标是否只是质量非常低,或者是否由 TabBarIOS 组件本身呈现了模糊性。
编辑:图标上的命名问题已修复,即使在使用 renderAsOriginal 之后,在颜色中渲染图标的问题仍然存在
【问题讨论】:
-
你可以添加标签的图像,因为它出现和你正在使用的 TabBarIOS 组件道具。
-
@while1,不幸的是,由于保密协议的原因,我不能。我可以告诉你,它们被灰色未选择的 tintColor 和
TabBar组件中提供的tintColor属性所覆盖。
标签: ios reactjs react-native tabbarios