CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2016 |
Maintained by iiyumewo.
NZHSwipeNavigationPageController can create a navigation bar favourably and simply with high customizability.
NZHSwipeNavigationPageController
.#import "NZHSwipeNavigationPageController"
.NZHSwipeNavigationPageController is a container for controllers, so we need arrays with controllers, button titles and some parameters for example.
UIViewController *demo1 = [[UIViewController alloc]init];
UIViewController *demo2 = [[UIViewController alloc]init];
UIViewController *demo3 = [[UIViewController alloc]init];
UIViewController *demo4 = [[UIViewController alloc]init];
UIViewController *demo5 = [[UIViewController alloc]init];
demo1.view.backgroundColor = FLAT_ORANGE;
demo2.view.backgroundColor = FLAT_ORANGERED;
demo3.view.backgroundColor = FLAT_ROSERED;
demo4.view.backgroundColor = FLAT_PURPLE;
demo5.view.backgroundColor = FLAT_DARKPURPLE;
NSArray *viewControllerArray = @[demo1, demo2, demo3, demo4, demo5];
NSArray *buttonTextArray = @[@"Home", @"Fund", @"Topic", @"Industry", @"Market"];
NZHSwipeNavigationPageController *barOnNavigationBarController =
[[NZHSwipeNavigationPageController alloc]initForSwipeByNavigationBarWithSubTitles:buttonTextArray
andControllers:viewControllerArray
andButtonWidth:70];
NZHSwipeNavigationPageController *deafultPatternController =
[[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision"
andButtonTitles:buttonTextArray
barHeight:40
buttonWidth:70
controllers:viewControllerArray];
//an arbitrary view for custom selector.
UIView *selectorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 8)];
selectorView.backgroundColor = [UIColor redColor];
selectorView.layer.cornerRadius = 6.0;
selectorView.layer.opacity = 0.3;
NZHSwipeNavigationPageController *customBottomSelectorController =
[[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision"
andButtonTitles:buttonTextArray
barHeight:40
buttonWidth:70
controllers:viewControllerArray];
[customBottomSelectorController setFlatAnimationalSelector:selectorView];
//an arbitrary view for custom selector.
UIView *selectorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 25)];
selectorView.backgroundColor = [UIColor redColor];
selectorView.layer.cornerRadius = 6.0;
selectorView.layer.opacity = 0.3;
NZHSwipeNavigationPageController *customMiddleSelectorController =
[[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision"
andButtonTitles:buttonTextArray
barHeight:40
buttonWidth:70
controllers:viewControllerArray];
[customMiddleSelectorController setMiddleAnimationalSelector:selectorView];
//an arbitrary view for custom selector.
UIView *selectorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 25)];
selectorView.backgroundColor = [UIColor redColor];
selectorView.layer.cornerRadius = 6.0;
selectorView.layer.opacity = 0.3;
NZHSwipeNavigationPageController *customAnimationSelectorController =
[[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision"
andButtonTitles:buttonTextArray
barHeight:40
buttonWidth:70
controllers:viewControllerArray];
[customAnimationSelectorController setMiddleAnimationalSelector:selectorView];
/*
* positionRatio is a float from 0 to 1 which is the progress between swiping from one button to another button next to.
* you can change the shape of selector bwteen its changing period in this block.
*/
__block NZHSwipeNavigationPageController *blockDemo = customAnimationSelectorController;
customAnimationSelectorController.customAnimationBlock = ^(UIScrollView *pageScrollView) {
CGFloat originSelectorHeight = 25;
CGFloat changedSelectorHeight;
if (blockDemo.positionRatio <= 0.5) {
changedSelectorHeight = originSelectorHeight*(1-blockDemo.positionRatio);
}else if (blockDemo.positionRatio > 0.5) {
changedSelectorHeight = originSelectorHeight*blockDemo.positionRatio;
}
CGRect rect = CGRectMake(blockDemo.selectorX, blockDemo.selectorY, blockDemo.animationView.frame.size.width, changedSelectorHeight);
blockDemo.animationView.frame = rect;
};