iOS-UIKit框架学习—UISlider

一个UISlider对象是一个可视化的控制,用来选择一个连续值范围从单一的值。滑块始终显示为单杠。拇指,注意到滑块的当前值,并更改设置的用户可以通过移动。


NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UISlider : UIControl 

// 当前的值
@property(nonatomic) float value;
// 滑动器的最小值
@property(nonatomic) float minimumValue;
// 滑动器的最大值
@property(nonatomic) float maximumValue;
// 左侧最小值图片 如
@property(nullable, nonatomic,strong) UIImage *minimumValueImage;
// 右侧最大值图片 如
@property(nullable, nonatomic,strong) UIImage *maximumValueImage;
// 是否拖动值改变后连续 默认YES
@property(nonatomic,getter=isContinuous) BOOL continuous;

// 最小的值的填充色
@property(nullable, nonatomic,strong) UIColor *minimumTrackTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// 最大的值的填充色
@property(nullable, nonatomic,strong) UIColor *maximumTrackTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// 滑块的填充色
@property(nullable, nonatomic,strong) UIColor *thumbTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

// 设置值并有动画效果
- (void)setValue:(float)value animated:(BOOL)animated;

// 设置不同状态下滑块图片
- (void)setThumbImage:(nullable UIImage *)image forState:(UIControlState)state;
// 设置不同状态下最小值图片
- (void)setMinimumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;
// 设置不同状态下最大值图片
- (void)setMaximumTrackImage:(nullable UIImage *)image forState:(UIControlState)state;

// 获取不同状态下滑块的图片
- (nullable UIImage *)thumbImageForState:(UIControlState)state;
// 获取不同状态下最小值的图片
- (nullable UIImage *)minimumTrackImageForState:(UIControlState)state;
// 获取不同状态下最大值的图片
- (nullable UIImage *)maximumTrackImageForState:(UIControlState)state;

// 获取当前滑块的图片
@property(nullable,nonatomic,readonly) UIImage *currentThumbImage;
// 获取当前最小值图片
@property(nullable,nonatomic,readonly) UIImage *currentMinimumTrackImage;
// 获取当前最大值图片
@property(nullable,nonatomic,readonly) UIImage *currentMaximumTrackImage;

// 返回最小值图片绘制的矩形
- (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
// 返回最大值图片绘制的矩形
- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
// 返回为滑块轨道绘制的矩形
- (CGRect)trackRectForBounds:(CGRect)bounds;
// 返回为拇指滑块轨道绘制的矩形
- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value;

@end

e.g.

UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(0, 100, SCREEN_WIDTH, 10)];
slider.minimumValue = 0.f;
slider.maximumValue = 100.f;
slider.thumbTintColor = [UIColor blueColor];
slider.minimumTrackTintColor = [UIColor yellowColor];
slider.maximumTrackTintColor = [UIColor redColor];
[slider setValue:50 animated:YES];
[self.view addSubview:slider];

你可能感兴趣的:(iOS-UIKit框架学习—UISlider)