作者:朱克锋
转载请注明出处:http://blog.csdn.net/linux_zkf
// 持续动作
- (void) updateThumb: (UISlider *) aSlider
{
//aSlider.value;
}
// 开始
- (void) startDrag: (UISlider *) aSlider
{
aSlider.center = CGPointMake(160.0f, 140.0f);
}
//结束
- (void) endDrag: (UISlider *) aSlider
{
aSlider.center = CGPointMake(160.0f, 140.0f);
}
{
//创建
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(20,20,200,10)];
slider.center = CGPointMake(160.0f, 140.0f);
slider.value = 0.0f;
// 回调与事件
[slider addTarget:self action:@selector(startDrag:) forControlEvents:UIControlEventTouchDown];
[slider addTarget:self action:@selector(updateThumb:) forControlEvents:UIControlEventValueChanged];
[slider addTarget:self action:@selector(endDrag:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
// 添加
[self.view addSubview:slider];
}