ios - Make 2 segments the size of 1 in UISegmentedControl -


i have uisegmentedcontrol 3 segments created in storyboard. want programmatically add segment, , make middle 2 segments size of 1 segment. here image illustrate:

in storyboard:

enter image description here

what want achieve programmatically:

enter image description here

this tried:

cgfloat segmentwidth = self.segment.frame.size.width;  [self.segment insertsegmentwithtitle:@"titlename" atindex:2 animated:no];  [self.segment setwidth:segmentwidth / 4 forsegmentatindex:1]; [self.segment setwidth:segmentwidth / 4 forsegmentatindex:2];  [self.segment setwidth:segmentwidth / 3 forsegmentatindex:0]; [self.segment setwidth:segmentwidth / 3 forsegmentatindex:3]; 

it didn't give me desirable effects. widths weird. how can widths second image above?

  1. half of 1/3 not 1/4. 1/6.

  2. you want set three of segments , leave last 1 set automatically fill remainder.

  3. don't run code - if do, segmented control may not have achieved final frame yet, segmentwidth wrong.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -