标签:uislider 自定义uislider的样式和滑块 ios 滑块 滑动触发事件
//自定义UISlider的样式和滑块
//轨道图片
UIImage *stetchLeftTrack = [UIImage imageNamed:@"thick"];
UIImage *stetchRightTrack = [UIImage imageNamed:@"thick"];
//滑块图片
UIImage *thumbImage = [UIImage imageNamed:@"thumb"];
//创建slider
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(30, 300, 300, 7)];
slider.backgroundColor = [UIColor clearColor];
slider.value = 1.0;
slider.minimumValue = 0.5;
slider.maximumValue = 1.0;
//设置轨道的图片
[slider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[slider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
//设置滑块的图片
//[slider setThumbImage:thumbImage forState:UIControlStateHighlighted];
[slider setThumbImage:thumbImage forState:UIControlStateNormal];
//滑动滑块添加事件
//滑动过程中不断触发事件
[slider addTarget:self action:@selector(onThumb:) forControlEvents:UIControlEventValueChanged];
//滑动完成添加事件
//滑动完成后触发事件
[slider addTarget:self action:@selector(endThumb:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:slider];
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:uislider 自定义uislider的样式和滑块 ios 滑块 滑动触发事件
原文地址:http://blog.csdn.net/lu_ca/article/details/46712545