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;
}
}
}
+3
user4679001
source
to share
2 answers
reduce / change ContentOffset - x
= -somepoints
it automatically appears on the left side
additional link apple doc for segment
+3
source to share