mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-25 21:05:40 +08:00
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:
committed by
facebook-github-bot-7
parent
8f0615080b
commit
2f23b30624
@@ -19,4 +19,6 @@
|
||||
@property (nonatomic, assign) float step;
|
||||
@property (nonatomic, assign) float lastValue;
|
||||
|
||||
@property (nonatomic, strong) UIImage *trackImage;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user