[英]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
元素更簡單。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.