0

I've built an interface using the XCode Interface Builder and there appears to be a strange bug with a custom segmented control. There's a single pixel line in between both buttons and it's not coming from the images. It appears to be some form of separator between the two segments but I can't figure out how to remove it! Any ideas on how to fix this would be much appreciated!

enter image description here

Community
  • 1
  • 1
Nick ONeill
  • 7,341
  • 10
  • 47
  • 61
  • 3
    It almost looks like you have your segmented control sitting on top of a bigger segmented control. Double check in interface builder that that background is a UIView or UIImageView, sometimes its possible you changed the class of the object in IB – Alex Gosselin Aug 05 '11 at 23:28
  • It's sitting on top of a UIImageView but it's a subview of a UIView ... the background image (stored in the UIImageView) is not the problem however – Nick ONeill Aug 05 '11 at 23:30
  • Ok time to investigate and narrow this down: Try it again with A) removing the segmented view from overtop, then B) put the segmented view back and slide it to the right/left some, to see if the little line follows it, then C) set the image view image to nothing. This should give us a better idea what the real source of the problem is. – Alex Gosselin Aug 06 '11 at 16:31
  • None of those things solve the problem ... I had already gone through that process. As I mentioned before the UIImageView has nothing to do with the problem. No matter which way you move it, the line stays there. It has to do with the default "Plain" style and 1 pixel from the background coming through. I just don't know how to remove it though – Nick ONeill Aug 06 '11 at 18:56
  • if you want help, tell us the specific behaviour you saw when you tried these suggestions, Does the line move or stay still when you move the segmented view? Does the line still show up if there is no background? Does the line still show up if there is no segmented view? I know these things will not "solve" the problem but they are designed to debug, I'm really trying to help. – Alex Gosselin Aug 07 '11 at 00:42
  • @Alex, When I remove the image view nothing happens ... the problem still exists. When I move the segmented control to the left or right the 1 pixel follows it. The line will not show up if there is no segmented view. – Nick ONeill Aug 07 '11 at 19:56
  • Ok so definitely coming from the segmented control, I'm curious then, if you set the background color of the segmented control to red or something visible, how big is the outline? You might be able to fix this with setClipsToBounds, since the source seems to be the segmented control, and these lines look like they are probably not within the bounds. – Alex Gosselin Aug 07 '11 at 21:22
  • Some posted answers [posted here](http://stackoverflow.com/questions/10562300/customizing-left-right-uisegmentedcontrol-buttons) might shed some more light on your issue. Hope that helps. – avelis Aug 05 '13 at 22:37

1 Answers1

0

This is caused by iOS drawing the separator line for the entire height of the segment control. I suppose your segment buttons have the actual buttons and the background in the same image. To fix this you'll have to have the background as a separate image and the individual segment buttons as another image as well. Then position the buttons correctly on the background image.

Inn0vative1
  • 2,014
  • 3
  • 27
  • 43