ios - Apply auto-layout to UISegmentedControl -


i set custom widths segments in uisegmentedcontrol. because of that, segmentedcontrol doesn't use auto-layout. (in storyboard, applied constraint on 4 sides of segmentedcontrol.)

here code:

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

here's image illustrate code does:

enter image description here

is there way add auto-layout segments?

the problem code in wrong place. put in viewdidlayoutsubviews , well.


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -