Transparent UISlider:
Steps:
Add the slider in the interface builder and create an iboutlet for it in the code, then link them together
then in the -viewdidload- method use the following code, to make the UISlider transparent
UIGraphicsBeginImageContextWithOptions((CGSize){ 1, 1 }, NO, 0.0f); UIImage *transparentImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
[slider setMinimumTrackImage:transparentImage forState:UIControlStateNormal]; [slider setMaximumTrackImage:transparentImage forState:UIControlStateNormal];
This should help you to get a transparent slider without any minimum and maximum images
Customized Minimum and Maximum Images:
If you want to customize it with your own images, then asusual link them together then in the viewdidload method use the following code.
Steps:
UIImage *minImage = [UIImage imageNamed:@"min.png"];
UIImage *maxImage = [UIImage imageNamed:@"max.png"];
UIImage *tumbImage= [UIImage imageNamed:@"slidebutton.png"]; minImage=[minImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
maxImage=[maxImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
[slider setMinimumTrackImage:minImage forState:UIControlStateNormal];
[slider setMaximumTrackImage:maxImage forState:UIControlStateNormal];
[slider setThumbImage:tumbImage forState:UIControlStateNormal];
No comments:
Post a Comment