Friend
Friend

Reputation: 7

how to set color for only selected segment index in segment controller

I have a UISegment controller,In this controller I want to change the selected segment controller tab color to orange.Other tab will be normal gray color. Please help me how to achieve this.

Upvotes: 0

Views: 1428

Answers (1)

Toseef Khilji
Toseef Khilji

Reputation: 17429

Simple way to get this using UISegmentedControl appearance

[[UISegmentedControl appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                         [UIColor orangeColor],UITextAttributeTextColor, nil]
                                               forState:UIControlStateSelected];

Upvotes: 2

Related Questions