簡體   English   中英

更改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元素更簡單。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM