一个带有自动出现刻度和两端饱和图像的滑动控件。直接来自 Hum. 的代码库。
要使用此控件,我们强烈建议使用 CocoaPods。为此请在您的 Podfile
中添加以下内容:
pod 'HUMSlider', ~>'1.0'
然后运行 pod install
。
一个快速编程示例,用于最常见的使用场景
HUMSlider *slider = [[HUMSlider alloc] init];
// Set the images to be saturated and desaturated
slider.minimumValueImage = [UIImage imageNamed:@"minImage"];
slider.maximumValueImage = [UIImage imageNamed:@"maxImage"];
// What color should the image be when the thumb is close to it?
slider.saturatedColor = [UIColor greenColor];
// What color should the image be when the thumb is not close to it?
slider.desaturatedColor = [[UIColor redColor] colorWithAlpha:0.5f];
// How many ticks do you want?
slider.sectionCount = 11; // This should be an odd number.
// What color should the ticks be?
slider.tickColor = [UIColor blackColor];
完整代码可在本仓库包含的示例应用程序中找到。
pointAdjustmentForCustomThumb
属性来补偿这一点。UIImageRenderingModeAlwaysTemplate
,以促进使用着色颜色对图像进行饱和和褪色。saturatedColor
或 desaturatedColor
属性,它将在两侧设置相同的颜色。使用 setSaturatedColor:forSide:
和 setDesaturatedColor:forSide
设置每侧的颜色。