开发者

When I select any segment in segmentControll it doesnot show highlighted

开发者 https://www.devze.com 2023-02-17 15:52 出处:网络
NSArray *itemArray = [NSArray arrayWithObjects:@\"one\", @\"Two\", @\"Three\", nil]; segmentControl = [[UISegmentedControl alloc] initWithItems:itemA开发者_运维百科rray];
NSArray *itemArray = [NSArray arrayWithObjects:@"one", @"Two", @"Three", nil];
segmentControl = [[UISegmentedControl alloc] initWithItems:itemA开发者_运维百科rray];
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??


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消