Skip to content

iOS version of Android PagerTabStrip written in Objective-C

Notifications You must be signed in to change notification settings

IbrahimKZ/IBRPagerTabStrip

Repository files navigation

IBRPagerTabStrip

IBRPagerTabStrip is a subclass of UIView that allows you to create Android PagerTabStrip element in your iOS application.

Look at the example below.

ibrpagertabstrip

How to use it in your project

IBRPagerTabStrip is written in Objective-C. It is very simple to use in your project. You just need to drag and drop 2 files IBRPagerTabStrip.h and IBRPagerTabStrip.m to your project. Add IBRPagerTabStrip view to your view controller's view. You can add it in storyboard or in code (as addSubview:). After that set it's data (titles and views). Look code example below.

UIView *view1 = [[UIView alloc] initWithFrame:[self.pagerTabStrip boundsForView]];
view1.backgroundColor = [UIColor redColor];
    
UIView *view2 = [[UIView alloc] initWithFrame:[self.pagerTabStrip boundsForView]];
view2.backgroundColor = [UIColor greenColor];

[self.pagerTabStrip addTabs:@[@{@"title": @"Section 1", @"view": view1},
                              @{@"title": @"Section 2", @"view": view2}]];

Method boundsForView returns size of one page which you can use in you child views. You can see how to use it in this example project.

How to customize it

We added some public properties, so you can customize your PagerTabStrip. Look at the code samples below.

self.pagerTabStrip.heightTab = 45;
self.pagerTabStrip.fontBtnTab = [UIFont systemFontOfSize:16];
self.pagerTabStrip.colorBtnTabTextActive = [UIColor redColor];
self.pagerTabStrip.colorBtnTabTextInactive = [UIColor colorWithWhite:1 alpha:.5];
self.pagerTabStrip.offsetXBtnTabText = 16;
self.pagerTabStrip.heightViewRunner = 1;
self.pagerTabStrip.colorViewRunner = [UIColor whiteColor];
self.pagerTabStrip.colorBackgroundViewRunner = [UIColor colorWithWhite:1 alpha:.5];

Delegate methods

IBRPagerTabStrip has @optional delegate methods. If you set your ViewController as delegate of IBRPagerTabStrip you can handle event when new page is selected. Look at the sample below.

...
self.pagerTabStrip.delegate = self;
...

#pragma mark - IBRPagerTabStrip delegate methods

- (void)pageChangedToPage:(int)page
{
    NSLog(@"page changed to: %i", page);
}

That's all ##Author Ibrakhim Nikishin (Github, LinkedIn) ##License The Unlicense You can use it as you want :-)

About

iOS version of Android PagerTabStrip written in Objective-C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published