更改 UISegmentController 中的分隔符颜色?
Change separator color in UISegmentController?
我的项目有UISegmentController
。我有灰色的颜色分离器。
黑线中间是分隔符,有白色分隔符,我要灰色分隔符?请建议一些代码。
我的密码是
- (void)changeColor{
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:83.0f/255.0f green:198.0f/255.0f blue:255.0f/255.0f alpha:1.0]} forState:UIControlStateSelected];
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:197.0f/255.0f green:197.0f/255.0f blue:197.0f/255.0f alpha:1.0]} forState:UIControlStateNormal];
}
您必须使用图像进行设置。请注意,您可以在选定和未选定的段之间或两个未选定的段之间使用单独的分隔符。
UISegmentedControl.setDividerImage(_:forLeftSegmentState:rightSegmentState:barMetrics:)
而不是使用 UISegmentedControl
我发现使用一组 UIControl
元素更简单。
我的项目有UISegmentController
。我有灰色的颜色分离器。
黑线中间是分隔符,有白色分隔符,我要灰色分隔符?请建议一些代码。 我的密码是
- (void)changeColor{
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:83.0f/255.0f green:198.0f/255.0f blue:255.0f/255.0f alpha:1.0]} forState:UIControlStateSelected];
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:197.0f/255.0f green:197.0f/255.0f blue:197.0f/255.0f alpha:1.0]} forState:UIControlStateNormal];
}
您必须使用图像进行设置。请注意,您可以在选定和未选定的段之间或两个未选定的段之间使用单独的分隔符。
UISegmentedControl.setDividerImage(_:forLeftSegmentState:rightSegmentState:barMetrics:)
而不是使用 UISegmentedControl
我发现使用一组 UIControl
元素更简单。