Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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
Ios 可切换UISegmentedControl_Ios_Swift_Xcode_Uiview_Uisegmentedcontrol - Fatal编程技术网

Ios 可切换UISegmentedControl

Ios 可切换UISegmentedControl,ios,swift,xcode,uiview,uisegmentedcontrol,Ios,Swift,Xcode,Uiview,Uisegmentedcontrol,我需要在Swift中实现SwipeableUISegmentedControl。我有uisegmentedcontrol视图,但我怎样才能像安卓系统中的标签栏一样在swipeable中工作呢 我有一个git MIT许可的项目,但我需要独立实现它。我需要一个简单的指导。使用UISegmentControl作为UIScrollView 我正在使用UIStoryboard设计我的视图。请按照以下步骤操作 步骤1:将UIScrollView添加到情节提要中 步骤2:UIScrollView的宽度应为视图

我需要在Swift中实现Swipeable
UISegmentedControl
。我有
uisegmentedcontrol
视图,但我怎样才能像安卓系统中的标签栏一样在swipeable中工作呢


我有一个git MIT许可的项目,但我需要独立实现它。我需要一个简单的指导。

使用
UISegmentControl
作为
UIScrollView

我正在使用
UIStoryboard
设计我的视图。请按照以下步骤操作

步骤1:将
UIScrollView
添加到情节提要中

步骤2:UIScrollView的宽度应为视图的宽度,高度约为60px

步骤3:向
UISectionControl
添加带有n个段的
UIScrollView
UISectionControl
的宽度应为100*n px(您可以根据需要进行计算)

步骤4:现在,在ViewController中为
UIScrollView
添加插座

步骤5:为
UIScrollView
添加contentsize,在ViewController的
viewDidLoad
中添加以下代码

self.scrollView.contentSize = CGSizeMake(100*n, 60);
请自行定制
UISegmentControl
。我已经测试过了&它对我有效


这应该适合你

使用
UISegmentControl
作为
UIScrollView

我正在使用
UIStoryboard
设计我的视图。请按照以下步骤操作

步骤1:将
UIScrollView
添加到情节提要中

步骤2:UIScrollView的宽度应为视图的宽度,高度约为60px

步骤3:向
UISectionControl
添加带有n个段的
UIScrollView
UISectionControl
的宽度应为100*n px(您可以根据需要进行计算)

步骤4:现在,在ViewController中为
UIScrollView
添加插座

步骤5:为
UIScrollView
添加contentsize,在ViewController的
viewDidLoad
中添加以下代码

self.scrollView.contentSize = CGSizeMake(100*n, 60);
请自行定制
UISegmentControl
。我已经测试过了&它对我有效


这应该适合你

如果参考底图视图是scrollview(应该是),您只需获取位置在contentview上的百分比,然后将段突出显示视图与
scrollViewDidScroll
中的视图一起移动。这个问题太广泛了。你已经试过什么了?请发布正在执行的工作。如果参考底图视图是scrollview(应该是),您只需获取位置相对于contentview的百分比,然后将段突出显示视图与
scrollViewDidScroll
中的部分突出显示视图一起移动即可。这个问题太广泛了。你已经试过什么了?请发布您正在执行的工作。