How to set the text of UISegmentedControl on the left side
I want the text of each segments are aligned to the left, so I tried UIControl contentHorizontalAlignment , but it did not work, so I try to redraw UISegmentedControl , since it will be displayed on the left, but if I choose one segment , the text segment will become a center alignment. Here is my code:
- (void)drawRect:(CGRect)rect {
NSLog(@"z %s", __FUNCTION__);
[super drawRect:rect];
[self changeToLeft];
}
-(void)changeToLeft
{
for (UIView *segV in self.subviews) {
for (UIView *subV in segV.subviews) {
subV.frameX = 0;
}
}
}
reduce / change ContentOffset - x
= -somepoints
it automatically appears on the left side
additional link apple doc for segment
When I set an arbitrary content offset in the storyboard and run the app, the text offset remains the same. Check out the video:
If your problem remains unresolved, please provide more description. I am more than happy to resolve your request.