How to know UISlider thumb position?
When I press a button I want to add a flag on the current slider thumb position.
How can I acquire the current thumb position so I can add the flag?
This is my synchronization code:
_positionSlider.value = _mediaplayer.position;
This is how the slider should look like:
Try This, First create UIImageView
@interface ViewController ()
{
UIImageView *imageView;
}
and write this below code in viewDiload() Function
imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.slider.frame.origin.x, self.slider.frame.origin.y-20, 20, 10)];
imageView.image = [UIImage imageNamed:@"navigateImage.png"];
[self.view addSubview:imageView];
[self.slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
and add this slider event function
-(void)sliderValueChanged:(UISlider *)slider{
CGRect trackRect = [self.slider trackRectForBounds:self.slider.bounds];
CGRect thumbRect = [self.slider thumbRectForBounds:self.slider.bounds
trackRect:trackRect
value:self.slider.value];
CGRect r = [imageView frame];
r.origin.x = thumbRect.origin.x;
[imageView setFrame:r];
NSLog(@"%f",thumbRect.origin.x);
}