ICViewPager icon indicating copy to clipboard operation
ICViewPager copied to clipboard

How to Highlight the Tab's Text?

Open LeeMing988 opened this issue 11 years ago • 4 comments

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?

LeeMing988 avatar Nov 03 '14 10:11 LeeMing988

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.

iltercengiz avatar Nov 26 '14 22:11 iltercengiz

@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.

edding avatar Dec 26 '14 07:12 edding

Any Update on Highlight the Tab's Text ?

kmuddapu avatar Aug 13 '15 17:08 kmuddapu

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.

shivanraptor avatar Oct 19 '15 09:10 shivanraptor