简体   繁体   中英

UISegmentedControl with buttons

So I have a UISegmentedControl with custom backgroundImage.. Here's how I set it up:

UISegmentedControl * segmentedCtrl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 178, 30)];
[segmentedCtrl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segmentedCtrl setTintColor:[UIColor clearColor]];

[segmentedCtrl setSegmentedControlStyle:UISegmentedControlStyleBezeled];
[segmentedCtrl insertSegmentWithImage:[UIImage imageNamed:@"btn-home-down.png"] atIndex:0 animated:NO];
.....
 [segmentedControl setImage:[UIImage imageNamed:@"btn-home.png"]  forSegmentAtIndex:0];
    [segmentedControl setImage:[UIImage imageNamed:@"btn-popular.png"] forSegmentAtIndex:1];
    [segmentedControl setImage:[UIImage imageNamed:@"btn-my-photos.png"] forSegmentAtIndex:2];
    [segmentedControl setImage:[UIImage imageNamed:@"btn-places.png"] forSegmentAtIndex:3];
    [segmentedControl setImage:[UIImage imageNamed:@"btn-my-likes"] forSegmentAtIndex:4];

Now the issue is this:

在此处输入图片说明

If you see closely between the segment image, on the divider line at the bottom I sort of have a white dot. All of my images are set to square.. why is this and how can I eliminate this?

Maybe you could get a UIImageView with only one pixel colored in with the color that the white pixel should be. Then you could placed it on top of the white pixel. This probably isn't the best way of doing this, but it works.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM