Skip to content

Commit ce7c0b7

Browse files
nicklockwoodfacebook-github-bot-6
authored andcommitted
Fixed image tinting
Summary: public A previous refactor introduced a bug where setting the tintColor of an <Image> to null no longer cleared the tint. This fixes it again. Reviewed By: javache Differential Revision: D2744279 fb-gh-sync-id: 1b5e0d546bf456d7b93e2ceee73c568c185c305c
1 parent 6355011 commit ce7c0b7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Libraries/Image/RCTImageView.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ - (void)setCapInsets:(UIEdgeInsets)capInsets
108108
}
109109
}
110110

111-
- (void)setTintColor:(UIColor *)tintColor
112-
{
113-
super.tintColor = tintColor;
114-
self.renderingMode = tintColor ? UIImageRenderingModeAlwaysTemplate : UIImageRenderingModeAlwaysOriginal;
115-
}
116-
117111
- (void)setRenderingMode:(UIImageRenderingMode)renderingMode
118112
{
119113
if (_renderingMode != renderingMode) {

Libraries/Image/RCTImageViewManager.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ - (UIView *)view
3333
RCT_EXPORT_VIEW_PROPERTY(onLoadEnd, RCTDirectEventBlock)
3434
RCT_REMAP_VIEW_PROPERTY(resizeMode, contentMode, UIViewContentMode)
3535
RCT_EXPORT_VIEW_PROPERTY(source, RCTImageSource)
36-
RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
36+
RCT_CUSTOM_VIEW_PROPERTY(tintColor, UIColor, RCTImageView)
37+
{
38+
// Default tintColor isn't nil - it's inherited from the superView - but we
39+
// want to treat a null json value for `tintColor` as meaning 'disable tint',
40+
// so we toggle `renderingMode` here instead of in `-[RCTImageView setTintColor:]`
41+
view.tintColor = [RCTConvert UIColor:json] ?: defaultView.tintColor;
42+
view.renderingMode = json ? UIImageRenderingModeAlwaysTemplate : defaultView.renderingMode;
43+
}
3744

3845
@end

0 commit comments

Comments
 (0)