Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the Segment control unselected

I have a problem, I want my UISegment controls to start all unselected when the app loads.

If someone can help on this matter I would be very thankful.

Best Regards.

like image 465
Bruno Avatar asked Feb 01 '12 12:02

Bruno


People also ask

What is segmented control?

A segmented control is a linear set of two or more segments, each of which functions as a button. Within a segmented control, all segments are usually equal in width. Like buttons, segments can contain text or images. Segments can also have text labels beneath them (or beneath the control as a whole).

How do you change the segment control color?

To change the overall color of the segmented control use its backgroundColor . To change the color of the selected segment use selectedSegmentTintColor . To change the color/font of the unselected segment titles, use setTitleTextAttributes with a state of . normal / UIControlStateNormal .

How do you change view controllers using segmented control?

To switch between the child view controllers, we use a segmented control. Click the + button in the top right to bring up the Library and add a segmented control to the navigation bar of the master view controller. Open MasterViewController. swift and create an outlet for the segmented control.


2 Answers

Either:

[mySegmentControl setSelectedSegmentIndex:-1];

or:

[mySegmentControl setSelectedSegmentIndex:UISegmentedControlNoSegment];

It's all in the apple docs too. Ref: http://developer.apple.com/library/ios/#documentation/uikit/reference/UISegmentedControl_Class/Reference/UISegmentedControl.html

like image 142
Totumus Maximus Avatar answered Oct 13 '22 10:10

Totumus Maximus


Just uncheck Selected checkbox from property

like image 27
Dipen Chudasama Avatar answered Oct 13 '22 10:10

Dipen Chudasama