SKPagerController
商城顶部标题滑动切换页面,非常实用的父子控制器小型框架。
语言
需求
- Xcode 8+
用法
- 您可以这样做。
#pragma mark - LazyLoad
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// self.selectIndex = 3; //default option
}
#pragma mark - LifeCyle
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpAllChildViewController];
[self setUpDisplayStyle:^(UIColor *__autoreleasing *titleScrollViewBgColor, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor, UIColor *__autoreleasing *proColor, UIFont *__autoreleasing *titleFont, CGFloat *titleButtonWidth, BOOL *isShowPregressView, BOOL *isOpenStretch, BOOL *isOpenShade) {
*titleScrollViewBgColor = [UIColor whiteColor]; //View background color
*norColor = [UIColor darkGrayColor]; //Unselected color (the font color is black by default)
*selColor = [UIColor orangeColor]; //Highlight the color (the font color is red by default)
*proColor = [UIColor purpleColor]; //Scrollbar color (by default the color of the title is selected)
*titleFont = [UIFont systemFontOfSize:16]; //FontSize (default fontSize is 15)
*titleButtonWidth = 100; //Width of the title button (with default)
/*
The following BOOL values are NO.
*/
*isShowPregressView = YES; //Whether to open the lower Pregress indicator under the heading.器
*isOpenStretch = YES; //Whether to open indicator stretch effect.
*isOpenShade = YES; //whether to open the font gradient.
}];
// [self setUpTitleScale:^(CGFloat *titleScale) { //The titleScale range is between 0 and 1 <0 or > 1, and the default is not resized by default. TitleScale opens the zoom, and the default is closed.
// *titleScale = 0.1;
// }];
//
// [self setUpProgressAttribute:^(CGFloat *progressLength, CGFloat *progressHeight, CGFloat *bottomDistance) {//ProgressLength sets the length of the bottom progress indicator, with the default value of 56 progressHeight default height of the button's width (and no greater than 10)
// *progressLength = 40;
// *progressHeight = 5;
// }];
// [self setUpTopTitleViewAttribute:^(CGFloat *topDistance, CGFloat *titleViewHeight) {
// *topDistance = 200;
// }];
}
#pragma mark - Add all childControllers.
- (void)setUpAllChildViewController
{
NSArray *titles = @[@"text01",@"text02",@"text03",@"text04",@"text05"];
for (NSInteger i = 0; i < titles.count; i++) {
UIViewController *vc = [UIViewController new];
vc.title = titles[i];
vc.view.backgroundColor = RandColor; //Random color
[self addChildViewController:vc];
}
}
安装
手动
- 将文件夹Extension中所有源文件(
CDDPagerController
)拖放到项目中。 - 在AppDelegate中导入头文件(
DCPageKit.h
)。 - 调用一个方法
CocoaPods
- 使用CocoaPods安装:
pod CDDPagerController
Swift版本
- 等待开发
协议
CDDPagerController
遵循MIT许可协议使用。有关更多信息,请参阅[许可证](https://open-source.org.cn/licenses/MIT)。