Latest 0.1.0
Homepage https://github.com/Magic-Unique/DoubleThumbSlider
License MIT
Platforms ios 7.0
Authors

DoubleThumbSlider

A slider with two thumbs.

双滑块控件

Warning !!

for 0.4.0 Refused by Apple

DTSlider use private APIs of UISlider class, It will cause your App refused by App Store.

DTSlider 用到了 UISlider 类中的私有 API,这将会导致你的 App 会被拒绝上传至 App Store。

for 0.1.0

DTSlider has confuse private APIs, but did not test on App Store.

DTSlider 混淆了私有 APIs,但是并没有做上传 App Store 测试。

Preview 效果图

gif

USAGE 使用方式

CocoaPods

pod 'DTSlider'

Source

drag DTSlider folder into your project.

Import

#import "DTSlider.h"
// DTSlider.h

@interface DTSlider : UISlider

@property (nonatomic, assign) float maxValue;

@property (nonatomic, assign) float minValue;

- (void)setMinValue:(float)minValue animated:(BOOL)animated;
- (void)setMaxValue:(float)maxValue animated:(BOOL)animated;
- (void)setMinValue:(float)minValue maxValue:(float)maxValue animated:(BOOL)animated;

@end

Create Instance

// in the other file.
DTSlider *slider = [[DTSlider alloc] init];
slider.maxValue = 100.0;    //  init value
slider.minValue = 0.0;      //  init value
[slider addTarget:self action:@selector(sender:event:) forControlEvents:UIControlEventValueChanged];

// selector
- (void)sender:(DTSlider *)sender event:(UIControlEvent)event {
    NSLog(@"min value:%fnmax value:%fn", sender.minValue, sender.maxValue);
}

//  set value without animation
slider.maxValue = 100.0;
slider.minValue = 0.0;

// set value with animation
[slider setMaxValue:100.0 animated:YES];
[slider setMinValue:1.0 animated:YES];

You can use the component like UISlider, and set the value with minValue and maxValue properties. In the mean time, you can also set target-action to touch the event of value changing, call getters of the properties to get new value. The value property of super-class is the value which changed by user, it means that value will equal to minValue or maxValue.

使用方式类似系统自带的 UISlider,可以通过 minValuemaxValue 来设置控件的值。同时,可以通过设置 target-action 的方式来监听 ValueChanged 事件,并且通过这两个属性来获取到新的值。父类中的 value 属性代表着用户变化的那个值,这意味着 value 属性可能等于 maxValue 也可能等于 minValue

LICENSE

MIT.

Latest podspec

{
    "name": "DTSlider",
    "version": "0.1.0",
    "summary": "A Slider extends UISlider with double thumb controller.",
    "description": "You can use for a range, such as: age-range, distance-range...nUse it as UISlider. Supporting custom image and setter with animation.",
    "homepage": "https://github.com/Magic-Unique/DoubleThumbSlider",
    "license": "MIT",
    "authors": {
        "u51b7u79cb": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/Magic-Unique/DoubleThumbSlider.git",
        "tag": "0.1.0"
    },
    "source_files": "DTSlider/**/*.{h,m}",
    "public_header_files": "DTSlider/DTSlider.h"
}

Pin It on Pinterest

Share This