1、UISlider添加监听事件
[darkSlider addTarget:selfaction:@selector(sliderValurChanged:forEvent:)forControlEvents:UIControlEventValueChanged];
// 实现方法
- (void)sliderValurChanged:(HDNewRGBSlider*)sliderforEvent:(UIEvent*)event {
UITouch*touchEvent = [[eventallTouches]anyObject];
switch(touchEvent.phase) {
case UITouchPhaseBegan:
DEBUGLOG(@"BrightnessVC=====开始拖动");
break;
case UITouchPhaseMoved:
DEBUGLOG(@"BrightnessVC=====正在拖动");
break;
case UITouchPhaseEnded:
{
intvalue = (int)(slider.value+0.5);
DEBUGLOG(@"BrightnessVC=====结束拖动=%d",value);
}
break;
default:
break;
}
}
网友评论