Add renderAsOriginal to selectedIcon
Summary: Hey, I've created a PR a few weeks ago #7264. It got merged in and then I received some emails and got mentioned in a few issues that it doesn't use renderAsOriginal prop on selectedIcon. Instead the app would use tint color. The problem can be seen here #7467. I've now added a method in TabBarItem that sets selectedIcon to renderAsOriginal if the prop is set. I added a "relay" icon to UIExplorer TabBarIOS example so you can see the item is now rendered in color as the image supplied. Oh and also should this PR be made from master. Had to work on this issue from 0.27 because the master was broken for me. Closes https://github.com/facebook/react-native/pull/7709 Differential Revision: D3339795 fbshipit-source-id: d8d4699bb617ecae8996a6627f3774c6473c19e0
This commit is contained in:
parent
1343248bbe
commit
ddc374fac8
|
@ -82,6 +82,7 @@ var TabBarExample = React.createClass({
|
|||
</TabBarIOS.Item>
|
||||
<TabBarIOS.Item
|
||||
icon={require('./flux.png')}
|
||||
selectedIcon={require('./relay.png')}
|
||||
renderAsOriginal
|
||||
title="More"
|
||||
selected={this.state.selectedTab === 'greenTab'}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -15,6 +15,7 @@
|
|||
|
||||
@property (nonatomic, copy) id /* NSString or NSNumber */ badge;
|
||||
@property (nonatomic, strong) UIImage *icon;
|
||||
@property (nonatomic, strong) UIImage *selectedIcon;
|
||||
@property (nonatomic, assign) UITabBarSystemItem systemIcon;
|
||||
@property (nonatomic, assign) BOOL renderAsOriginal;
|
||||
@property (nonatomic, assign, getter=isSelected) BOOL selected;
|
||||
|
|
|
@ -92,6 +92,17 @@ RCT_ENUM_CONVERTER(UITabBarSystemItem, (@{
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setSelectedIcon:(UIImage *)selectedIcon
|
||||
{
|
||||
_selectedIcon = selectedIcon;
|
||||
|
||||
if (_renderAsOriginal) {
|
||||
self.barItem.selectedImage = [_selectedIcon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
} else {
|
||||
self.barItem.selectedImage = _selectedIcon;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIViewController *)reactViewController
|
||||
{
|
||||
return self.superview.reactViewController;
|
||||
|
|
|
@ -25,7 +25,7 @@ RCT_EXPORT_VIEW_PROPERTY(badge, id /* NSString or NSNumber */)
|
|||
RCT_EXPORT_VIEW_PROPERTY(renderAsOriginal, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(selected, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(icon, UIImage)
|
||||
RCT_REMAP_VIEW_PROPERTY(selectedIcon, barItem.selectedImage, UIImage)
|
||||
RCT_EXPORT_VIEW_PROPERTY(selectedIcon, UIImage)
|
||||
RCT_EXPORT_VIEW_PROPERTY(systemIcon, UITabBarSystemItem)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
|
||||
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
|
||||
|
|
Loading…
Reference in New Issue