更改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];