Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

How to Highlight the Tab's Text? #91

Open
LeeMing988 opened this issue Nov 3, 2014 · 4 comments
Open

How to Highlight the Tab's Text? #91

LeeMing988 opened this issue Nov 3, 2014 · 4 comments

Comments

@LeeMing988
Copy link

Hi there, Currently I am using this framework to developing something.

When i am in current tab. I would like the Text Colour to change to white colour. any idea how to did this?

@iltercengiz
Copy link
Owner

Currently there's not an implementation for this kind of feature, but with a quick thought, it came to my mind that you can track the tab views you're providing to ViewPagerController and edit them in your subclass.

@edding
Copy link

edding commented Dec 26, 2014

@LeeMing988
A temporary solution is to add some lines in the - (void)setActiveTabIndex:(NSUInteger)activeTabIndex method.

like this:

// Set to-be-inactive tab unselected
activeTabView = [self tabViewAtIndex:self.activeTabIndex];
activeTabView.selected = NO;
labelSubview = activeTabView.subviews[0];
labelSubview.textColor = [UIColor blackColor];

 // Set to-be-active tab selected
activeTabView = [self tabViewAtIndex:activeTabIndex];
activeTabView.selected = YES;
labelSubview = activeTabView.subviews[0];
labelSubview.textColor = [UIColor whiteColor];

Hope this could help you.

@kmuddapu
Copy link

Any Update on Highlight the Tab's Text ?

@shivanraptor
Copy link

Here is my solution, referencing @EdwardDing's solution:

In ViewPagerController.h, change the ViewPagerComponent ENUM to:

typedef NS_ENUM(NSUInteger, ViewPagerComponent) {
    ViewPagerIndicator,
    ViewPagerTabsView,
    ViewPagerContent,
    ViewPagerSelectedText,
    ViewPagerUnselectedText
};

In ViewPagerController.m:

// Set to-be-inactive tab unselected
activeTabView = [self tabViewAtIndex:self.activeTabIndex];
activeTabView.selected = NO;
UILabel* labelSubview = activeTabView.subviews[0];
labelSubview.textColor = [self.delegate viewPager:self colorForComponent:ViewPagerUnselectedText withDefault:[UIColor blackColor]];

// Set to-be-active tab selected
activeTabView = [self tabViewAtIndex:activeTabIndex];
activeTabView.selected = YES;
labelSubview = activeTabView.subviews[0];
labelSubview.textColor = [self.delegate viewPager:self colorForComponent:ViewPagerSelectedText withDefault:[UIColor grayColor]];

Hope @iltercengiz can merge these to next version, along with the Y offset functionalities.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants