如何在iPhone的自定义滑块中创建滑块。目前,我正在使用从“ xib”(接口生成器)中选择的滑块,但它向我显示了普通滑块。但是我需要使用自己的按钮进行自定义并显示文本的滑块


  滑动开始


我该怎么做,请帮帮我。

最佳答案

你可以像

UISlider *mySlider;
mySlider = [[UISlider alloc]init];
/* Slider Customization */
[mySlider setThumbImage:[UIImage imageNamed:@"yourimage.png"] forState:UIControlStateNormal];
/*the above line will sets a custom image for your slider ball i.e; thumb image*/

/* the below code will make your slider line custom */
UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @"lineImage.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];
UIImage *sliderRightTrackImage = [[UIImage imageNamed: @"lineImage.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];

[mySlider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal];
[mySlider setMaximumTrackImage: sliderRightTrackImage forState: UIControlStateNormal];
/* end of Slider Customization */
[mySlider release];

10-08 05:46
查看更多