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:
is there way add auto-layout
segments
?
the problem code in wrong place. put in viewdidlayoutsubviews
, well.
Comments
Post a Comment