Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何设置滑块上的图像?_Iphone_Uislider_Slidetoggle - Fatal编程技术网

Iphone 如何设置滑块上的图像?

Iphone 如何设置滑块上的图像?,iphone,uislider,slidetoggle,Iphone,Uislider,Slidetoggle,我想使用上面的图像滑块控制。当用户播放幻灯片时,类别选项卡将高亮显示,所有人都很高兴。那么,我如何使用滑块控制器,使我可以得到这个功能?如何使用滑块控制?您显示的控件是一个段控制,您可以使用此代码设置图像 The simplest solution would be to render a UIImage behind the control to represent the track. The thumbknob can be changed with: [mySlider setThum


我想使用上面的图像滑块控制。当用户播放幻灯片时,类别选项卡将高亮显示,所有人都很高兴。那么,我如何使用滑块控制器,使我可以得到这个功能?如何使用滑块控制?

您显示的控件是一个段控制,您可以使用此代码设置图像

The simplest solution would be to render a UIImage behind the control to represent the track. The thumbknob can be changed with:

[mySlider setThumbImage:[UIImage imageNamed:@"thumb_image.png"] forState:UIControlStateNormal];

A side-effect of this is that the track isn't rendered unless you provide your own. This, combined with the UIImage, provide you with a custom UISlider without you having to subclass anything.
UISegmentedControl* offlineSegment=[[UISegmentedControl alloc] initWithItems:[[[NSMutableArray alloc] initWithObjects:@"ON",@"OFF",nil] autorelease]];
    [offlineSegment setFrame:CGRectMake(210,50,90,30)];
    offlineSegment.tintColor=[UIColor greenColor];
    offlineSegment.selectedSegmentIndex=0;

    offlineSegment.segmentedControlStyle=UISegmentedControlStyleBezeled;
    [locationSegment setImage:[UIImage imageNamed:@"onSelected.png"] forSegmentAtIndex:0];
    [locationSegment setImage:[UIImage imageNamed:@"off.png"] forSegmentAtIndex:1];
    [offlineSegment addTarget:self action:@selector(offlineSetting:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:offlineSegment];
    [offlineSegment release];

希望这将对您有所帮助

我不确定这是否能回答您的问题,但我看过github的这个项目,看起来有点像这样


我需要这个滑块。好的,然后你需要为UIView类创建子类,并在那里绘制滑块。然后你可以实现这一点。否则,不使用自定义实现并不容易。你可以给出如何自定义滑块和添加段控制的代码吗?robin在下面提供了下载代码的链接。你可以从这里了解如何自定义它。即使这些代码也是如果您已经检查过,则会很有帮助。。。