I am using a UIslider to move a UIImage left and right on the screen. When the UISlider is totally on the left the image will be to a certain position on the X atis on the left of the screen, and when the slider is totally to the right, the image is on the right of the screen. If for example I want to give the image flexibility movement of 600px, how can I do that?
-(IBAction)sliderValueChanged:(UISlider *)sender
{
if (sender.value >= 0.5) {
int value;
value = sender.value * 6;
[photoView setFrame:CGRectMake(photoView.frame.origin.x + value,
PhotoView.frame.origin.y,photoView.frame.size.width,photoView.frame.size.height)];
}else{
int value;
value = sender.value * -6;
[photoView setFrame:CGRectMake(photoView.frame.origin.x + value,
photoView.frame.origin.y,photoView.frame.size.width,photoView.frame.size.height)];
}
…this was my guess
How about something like this,
You can also do this by changing
photoView.frame.origin.x + valuetofloatValue + valuewherefloatValueis some fixed number based on where you want to set the photoView. Also calculate value asvalue = sender.value * constantwhereconstantagain depends on how much you need to move it for each slider movement.Check documentation for more details on properties