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

Implements new option: yOffset #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ICViewPager/Controller/HostViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ - (CGFloat)viewPager:(ViewPagerController *)viewPager valueForOption:(ViewPagerO
return 1.0;
case ViewPagerOptionFixLatterTabsPositions:
return 1.0;
case ViewPagerOptionYOffset:
return 0.0f;
default:
return value;
}
Expand Down
3 changes: 2 additions & 1 deletion ICViewPager/ICViewPager/ViewPagerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ typedef NS_ENUM(NSUInteger, ViewPagerOption) {
ViewPagerOptionStartFromSecondTab,
ViewPagerOptionCenterCurrentTab,
ViewPagerOptionFixFormerTabsPositions,
ViewPagerOptionFixLatterTabsPositions
ViewPagerOptionFixLatterTabsPositions,
ViewPagerOptionYOffset
};

/**
Expand Down
12 changes: 9 additions & 3 deletions ICViewPager/ICViewPager/ViewPagerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define kCenterCurrentTab 0.0
#define kFixFormerTabsPositions 0.0
#define kFixLatterTabsPositions 0.0
#define kYOffset 0.0

#define kIndicatorColor [UIColor colorWithRed:178.0/255.0 green:203.0/255.0 blue:57.0/255.0 alpha:0.75]
#define kTabsViewBackgroundColor [UIColor colorWithRed:234.0/255.0 green:234.0/255.0 blue:234.0/255.0 alpha:0.75]
Expand Down Expand Up @@ -210,18 +211,23 @@ - (void)layoutSubviews {
}
}

CGFloat yOffset = kYOffset;
if ([self.delegate respondsToSelector:@selector(viewPager:valueForOption:withDefault:)]) {
yOffset = [self.delegate viewPager:self valueForOption:ViewPagerOptionYOffset withDefault:yOffset];
}

CGRect frame = self.tabsView.frame;
frame.origin.x = 0.0;
frame.origin.y = [self.tabLocation boolValue] ? topLayoutGuide : CGRectGetHeight(self.view.frame) - [self.tabHeight floatValue];
frame.origin.y = (yOffset) + ([self.tabLocation boolValue] ? topLayoutGuide : CGRectGetHeight(self.view.frame) - [self.tabHeight floatValue]);
frame.size.width = CGRectGetWidth(self.view.frame);
frame.size.height = [self.tabHeight floatValue];
self.tabsView.frame = frame;

frame = self.contentView.frame;
frame.origin.x = 0.0;
frame.origin.y = [self.tabLocation boolValue] ? topLayoutGuide + CGRectGetHeight(self.tabsView.frame) : topLayoutGuide;
frame.origin.y = (yOffset) + ([self.tabLocation boolValue] ? topLayoutGuide + CGRectGetHeight(self.tabsView.frame) : topLayoutGuide);
frame.size.width = CGRectGetWidth(self.view.frame);
frame.size.height = CGRectGetHeight(self.view.frame) - (topLayoutGuide + CGRectGetHeight(self.tabsView.frame)) - CGRectGetHeight(self.tabBarController.tabBar.frame);
frame.size.height = (CGRectGetHeight(self.view.frame) - (topLayoutGuide + CGRectGetHeight(self.tabsView.frame)) - CGRectGetHeight(self.tabBarController.tabBar.frame)) - yOffset;
self.contentView.frame = frame;
}

Expand Down