added a property to set a track image to slider ios

Summary: this change will allow the slider to have different track images.

Sets an image for the sliderIOS's track. It only supports images that are included as assets.
Closes https://github.com/facebook/react-native/pull/3850

Reviewed By: svcscm

Differential Revision: D2659680

Pulled By: nicklockwood

fb-gh-sync-id: faf6ddea1077b081c1fc05f8f110b669cef9902c
This commit is contained in:
Manuel Nakamurakare
2015-11-17 08:43:13 -08:00
committed by facebook-github-bot-7
parent 8f0615080b
commit 2f23b30624
4 changed files with 24 additions and 0 deletions

View File

@@ -19,4 +19,6 @@
@property (nonatomic, assign) float step;
@property (nonatomic, assign) float lastValue;
@property (nonatomic, strong) UIImage *trackImage;
@end

View File

@@ -32,4 +32,19 @@
super.value = _unclippedValue;
}
- (void)setTrackImage:(UIImage *)trackImage
{
if (trackImage != _trackImage) {
_trackImage = trackImage;
CGFloat width = trackImage.size.width;
UIImage *minimumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){0, width, 0, 0}];
UIImage *maximumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){0, 0, 0, width}];
[super setMinimumTrackImage:minimumTrackImage forState:UIControlStateNormal];
[super setMaximumTrackImage:maximumTrackImage forState:UIControlStateNormal];
}
}
@end

View File

@@ -76,6 +76,7 @@ static void RCTSendSliderEvent(RCTSlider *sender, BOOL continuous)
RCT_EXPORT_VIEW_PROPERTY(value, float);
RCT_EXPORT_VIEW_PROPERTY(step, float);
RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage);
RCT_EXPORT_VIEW_PROPERTY(minimumValue, float);
RCT_EXPORT_VIEW_PROPERTY(maximumValue, float);
RCT_EXPORT_VIEW_PROPERTY(minimumTrackTintColor, UIColor);