Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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
更改Objective-C中分段控件的外边框颜色_Objective C_Uisegmentedcontrol - Fatal编程技术网

更改Objective-C中分段控件的外边框颜色

更改Objective-C中分段控件的外边框颜色,objective-c,uisegmentedcontrol,Objective C,Uisegmentedcontrol,我有一个分段的控件对象,我想更改外边框的颜色,同时保留两个选项之间的线。我目前拥有以下代码: self.segmentedControl.tintColor = [UIColor whiteColor]; //sets border and text to white [self.segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor darkGrayColor]} forState:U

我有一个分段的控件对象,我想更改外边框的颜色,同时保留两个选项之间的线。我目前拥有以下代码:

self.segmentedControl.tintColor = [UIColor whiteColor]; //sets border and text to white

[self.segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor darkGrayColor]} forState:UIControlStateNormal]; //sets selected segment text to dark grey

但是,此代码还将两个选项之间的行设置为白色。有没有办法只更改外边框的颜色,或者我应该只将两个按钮相邻放置?

UISegmentedControl没有您所说的选项。您必须使用UIView、UIButton或UILabel等实现自己的自定义分段控制器。

通过这种方式,您可以做到:

segControl.tintColor = [UIColor whiteColor];
如果要更改文本颜色白色,请使用以下代码段:

[segControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];