3

I want every segment text is alignment left, so I had try UIControl contentHorizontalAlignment, but it don't work, so I try to redraw UISegmentedControl, at beginning it will show at left, but if I choose one segment, the segment text will become alignment centre. 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;
    }
  }
}
Sarat Patel
  • 856
  • 13
  • 32
  • Please refer to the question : http://stackoverflow.com/questions/21980424/text-alignment-issue-when-i-set-the-custom-font – manish_kumar Aug 07 '15 at 09:50

2 Answers2

4

enter image description here

reduce/Change ContentOffset - x =-somepoints it automatically comes on left side

enter image description here

additional reference of apple Document for Segment

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
1

CHeck image for steps

When I set the custom content offset in the storyboard and run the app, the text's offset remains same. Check video:Video having proof

If your problem remains unsolved, then please give more description. I am more than happy to solve your query.

pkc456
  • 8,350
  • 38
  • 53
  • 109