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

Apply Various patches #104

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions ICViewPager/Controller/ContentViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>
#define NSLog(__FORMAT__, ...)

@interface ContentViewController : UIViewController

Expand Down
36 changes: 24 additions & 12 deletions ICViewPager/Controller/HostViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@interface HostViewController () <ViewPagerDataSource, ViewPagerDelegate>

@property (nonatomic) NSUInteger numberOfTabs;
@property (strong, nonatomic) NSArray* tabTitles;

@end

Expand All @@ -25,20 +26,13 @@ - (void)viewDidLoad {
self.delegate = self;

self.title = @"View Pager";
self.tabTitles = @[@"DESTACADOS", @"ARTE & CULTURA",@"COMIDA",@"CINE", @"MUSICA", @"TEATRO", @"DEPORTE", @"HAPPY HOURS"];

// Keeps tab bar below navigation bar on iOS 7.0+
// if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
// self.edgesForExtendedLayout = UIRectEdgeNone;
// }

self.navigationItem.rightBarButtonItem = ({

UIBarButtonItem *button;
button = [[UIBarButtonItem alloc] initWithTitle:@"Tab #5" style:UIBarButtonItemStylePlain target:self action:@selector(selectTabWithNumberFive)];

button;
});

}
- (void)viewDidAppear:(BOOL)animated {

Expand All @@ -58,6 +52,7 @@ - (void)setNumberOfTabs:(NSUInteger)numberOfTabs {

// Set numberOfTabs
_numberOfTabs = numberOfTabs;
_numberOfTabs = self.tabTitles.count;

// Reload data
[self reloadData];
Expand Down Expand Up @@ -88,19 +83,22 @@ - (UIView *)viewPager:(ViewPagerController *)viewPager viewForTabAtIndex:(NSUInt
UILabel *label = [UILabel new];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont systemFontOfSize:12.0];
label.text = [NSString stringWithFormat:@"Tab #%i", index];
label.text = [NSString stringWithFormat:@"%@", self.tabTitles[index]];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor blackColor];
[label sizeToFit];

return label;
}
-(NSArray*) viewPagerTabs {
return self.tabTitles;
}

- (UIViewController *)viewPager:(ViewPagerController *)viewPager contentViewControllerForTabAtIndex:(NSUInteger)index {

ContentViewController *cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];

cvc.labelString = [NSString stringWithFormat:@"Content View #%i", index];
cvc.labelString = [NSString stringWithFormat:@"Content View #%lu", (unsigned long)index];

return cvc;
}
Expand All @@ -114,16 +112,30 @@ - (CGFloat)viewPager:(ViewPagerController *)viewPager valueForOption:(ViewPagerO
case ViewPagerOptionCenterCurrentTab:
return 1.0;
case ViewPagerOptionTabLocation:
return 0.0;
return 1.0;
case ViewPagerOptionTabHeight:
return 49.0;
case ViewPagerOptionTabOffset:
return 36.0;
case ViewPagerOptionTabWidth:
return UIInterfaceOrientationIsLandscape(self.interfaceOrientation) ? 128.0 : 96.0;
case ViewPagerOptionFixFormerTabsPositions:
return 1.0;
return 0.0;
case ViewPagerOptionFixLatterTabsPositions:
return 0.0;
case ViewPagerOptionLowerTabBar:
return 0.0;
case ViewPagerOptionRelativeTitleSizes:
return 1.0;
case ViewPagerOptionRelativeTitlePadding:
return 20.0;
case ViewPagerOptionTaBarBottomPadding:

return 0.0;
case ViewPagerOptionScrollBounce:

return UIInterfaceOrientationIsLandscape(self.interfaceOrientation) ? 1.0 : 0.0;
case ViewPagerOptionShowTabs:
return 1.0;
default:
return value;
Expand Down
15 changes: 13 additions & 2 deletions ICViewPager/ICViewPager/ViewPagerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>
#define NSLog(__FORMAT__, ...)

/**
* Every option has a default value.
Expand All @@ -19,6 +20,10 @@
* ViewPagerOptionCenterCurrentTab: 1.0: YES, 0.0: NO, defines if tabs should be centered, with the given tabWidth. Defaults to NO
* ViewPagerOptionFixFormerTabsPositions: 1.0: YES, 0.0: NO, defines if the active tab should be placed margined by the offset amount to the left. Effects only the former tabs. If set 1.0 (YES), first tab will be placed at the same position with the second one, leaving space before itself. Defaults to NO
* ViewPagerOptionFixLatterTabsPositions: 1.0: YES, 0.0: NO, like ViewPagerOptionFixFormerTabsPositions, but effects the latter tabs, making them leave space after themselves. Defaults to NO

* ViewPagerOptionRelativeTitleSizes: 1.0: YES, 0.0: NO, if YES will calculate the tab width based on the view's width. Defaults to NO
* ViewPagerOptionRelativeTitlePadding: The spacing between tabs, defaults to 15.0. This will only have an effect if ViewPagerOptionRelativeTitleSizes is YES
* ViewPagerOptionLowerTabBar: Lowers the tabs n the view controller by the amount. Defaults to 0.0 which makesthe tabs be on top or on bottom depending on ViewPagerOptionTabLocation. Accepts negative values to raise the tabs.
*/
typedef NS_ENUM(NSUInteger, ViewPagerOption) {
ViewPagerOptionTabHeight,
Expand All @@ -28,7 +33,14 @@ typedef NS_ENUM(NSUInteger, ViewPagerOption) {
ViewPagerOptionStartFromSecondTab,
ViewPagerOptionCenterCurrentTab,
ViewPagerOptionFixFormerTabsPositions,
ViewPagerOptionFixLatterTabsPositions
ViewPagerOptionFixLatterTabsPositions,
ViewPagerOptionRelativeTitleSizes,
ViewPagerOptionRelativeTitlePadding,
ViewPagerOptionLowerTabBar,
ViewPagerOptionTaBarBottomPadding,
ViewPagerOptionScrollBounce,
ViewPagerOptionShowTabs

};

/**
Expand Down Expand Up @@ -154,7 +166,6 @@ typedef NS_ENUM(NSUInteger, ViewPagerComponent) {
* @return A view which will be shown as content
*/
- (UIView *)viewPager:(ViewPagerController *)viewPager contentViewForTabAtIndex:(NSUInteger)index;

@end

#pragma mark delegate
Expand Down
Loading