Jean-Luc Godard
Jean-Luc Godard

Reputation: 1883

When I select any segment in segmentControll it doesnot show highlighted

NSArray *itemArray = [NSArray arrayWithObjects:@"one", @"Two", @"Three", nil];
segmentControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentControl.frame = CGRectMake(5, 5, 325, 35);
segmentControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentControl.tintColor = [UIColor blackColor];

[self changeUISegmentFont:segmentControl];
//[self.view addSubview:segmentControl];
self.navigationItem.titleView = segmentControl;
[segmentControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];

This is my code of segment control and my problem is ..

When I select any segment it does not show me that that segment is selected.. I mean it is not shown highlighted..

can Anyone tell me what the problem is??

Upvotes: 1

Views: 534

Answers (1)

Adarsh V C
Adarsh V C

Reputation: 2314

Change the following line in your code.


segmentControl.tintColor = [UIColor blackColor];

to

segmentControl.tintColor = [UIColor grayColor];

Actually the segment is getting selected but It is not visible to you, because black color is the default color in selected mode.

Upvotes: 3

Related Questions