CarbonKit
CarbonKit copied to clipboard
Center Tabs
How to center the tabs if they fit on screen and don't need scrolling?
It's not a feature but you can try to hack carbonTabSwipeScrollView. contentInsets
Try this
CGRect frm = carbonTabSwipeNavigation.carbonSegmentedControl.frame;
frm.size.width = CGRectGetWidth(carbonTabSwipeNavigation.view.frame);
[carbonTabSwipeNavigation.carbonSegmentedControl setFrame:frm];
Doesn't really do what I want, I want the tabs centered not expanded
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));
}
}
@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!
Also doesn't work in a tab bar controller when switching tabs :(
Or pushing popping view controller
@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 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.
when i add width to tabs it looks like uneven space between tabs