Pregunta

Picture says it all (see arrows). Any way I can make sure the background is transparent? If I set the background to transparent on the UISegmentedControl it sets the button color to transparent too, but we want to avoid this.

enter image description here

Clarification: We want to keep the buttons white, but get rid of the white stuff in the corners. Setting background to white does this but then makes the buton background transparent too, which we don't want.

enter image description here

Update: Now looks as follows, after trying Astri's suggestion and setting corner radius to 5. Still, there is a white space on the right.

¿Fue útil?

Solución

After the clarification:

Try this:

yourSegmententControl.layer.cornerRadius = 5;

Make sure you import Quartz

Otros consejos

I experienced the same white space on the right problem when I explicitly set the width of the UISegmentedControl.

To fix it, do not set the width of the segmented control – just set the width of each segment instead.

// Determine your segment width
CGFloat segmentWidth = 50.0;

// Loop through the segments
for (NSInteger i=0; i<mySegmentedControl.numberOfSegments; i++) {

  // Set the width of each segment
  [mySegmentedControl setWidth:segmentWidth forSegmentAtIndex:i];
}

The background colors of the views of the controlls are already transparent, so you need to set them too to whatever color you want, not just the background color of the view of the segmented controll. Keep in mind that the controlls have different configurations for their state.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top