CarbonKit icon indicating copy to clipboard operation
CarbonKit copied to clipboard

Center Tabs

Open MobileMon opened this issue 8 years ago • 9 comments

How to center the tabs if they fit on screen and don't need scrolling?

MobileMon avatar May 13 '16 14:05 MobileMon

It's not a feature but you can try to hack carbonTabSwipeScrollView. contentInsets

ermalkaleci avatar May 14 '16 11:05 ermalkaleci

Try this

CGRect frm = carbonTabSwipeNavigation.carbonSegmentedControl.frame;
frm.size.width = CGRectGetWidth(carbonTabSwipeNavigation.view.frame);
 [carbonTabSwipeNavigation.carbonSegmentedControl setFrame:frm];

zurce avatar May 27 '16 01:05 zurce

Doesn't really do what I want, I want the tabs centered not expanded

MobileMon avatar May 27 '16 12:05 MobileMon

in CarbonTabScrollView.m file, line 80 add this code:

CGFloat selfWidth = CGRectGetWidth(self.bounds);
        if ( [_carbonSegmentedControl getWidth]<CGRectGetWidth(self.bounds))
        {
            CGFloat difference = selfWidth -  [_carbonSegmentedControl getWidth];
            self.frame = CGRectMake(difference/2.0f, 0, selfWidth, CGRectGetHeight(self.bounds));

        }
        else
        {
            CGRect frame = self.frame;
            if (!CGRectEqualToRect(frame, CGRectMake(0, 0, selfWidth, CGRectGetHeight(self.bounds))))
            {
                self.frame = CGRectMake(0, 0, selfWidth, CGRectGetHeight(self.bounds));
            }
        }

bama

haashem avatar Jun 04 '16 14:06 haashem

@hashemp206

Works except for when rotating between orientations and the last tab is selected

Actually that problem is persistent even without this code so I guess its a separate issue. I will close this issue, thanks for your help!

MobileMon avatar Jun 08 '16 19:06 MobileMon

Also doesn't work in a tab bar controller when switching tabs :(

Or pushing popping view controller

MobileMon avatar Sep 14 '16 14:09 MobileMon

@hashemp206 can you please let me know how to add space between them i tried setTabExtraWidth but its adding width to tab....i need to add space between the tabs.

rk28286 avatar May 07 '17 17:05 rk28286

@rk28286 I suggest don't add space between tab, instead increase the with of tabs. because when user tap between "tab gaps", nothing will happen. and this is not the user is looking for, he want to switch between tabs, by tapping anywhere in titleSlider.

haashem avatar May 09 '17 06:05 haashem

when i add width to tabs it looks like uneven space between tabs

rk28286 avatar May 29 '17 22:05 rk28286