The problem with UISlider: printing slider values ​​and changing the style

I am having a problem with UISlider programming.

1) style: I know that we need to set the minimum and maximum image. I'm just not sure which images and image links will be great? I want to change only from blue to black!

2), my code for UISlider is this:

in the header file:

UISlider *slider;

in the code file:

 //slider
 CGRect frame=CGRectMake(10, 70, 300, 10);
 photoSlider=[[UISlider alloc] initWithFrame:frame];
 photoSlider.minimumValue=0.0;
 photoSlider.maximumValue=90.0; //maximumPhotoImage
 photoSlider.continuous=NO;
 photoSlider.value=10.0;
 photoSlider.backgroundColor=[UIColor clearColor];
 //photoSlider

 [photoSlider addTarget:self action:@selector(updateImage:)   forControlEvents:UIControlEventValueChanged];
 [self.view addSubview:photoSlider];

- (void) updateImage:(id) sender  
{
   NSLog(@"val: %d",photoSlider.value);
}

The values ​​that I get from the function are 0 at both ends and a very big value between them (both positive and negative ... random values).

Can anybody help me? Thank.

+3
source share
1 answer

1, , , ( 1 ):
enter image description here
setMinimumTrackImage:forState::

UIImage *minTrackImg = [[UIImage imageNamed:@"MinimumTrackImage.png"] 
    stretchableImageWithLeftCapWidth:4 topCapHeight:0];
[photoSlider setMinimumTrackImage:minTrackImg forState:UIControlStateNormal];


2 , value float, %f %d (. ):

NSLog(@"val: %f",photoSlider.value);
+2

All Articles