DPPageViewController
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install
。
需求
安装
DPPageViewController 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "DPPageViewController"
用法
快速使用
#import "DPPageViewController.h"
DPPageViewController *pagevc = [[DPPageViewController alloc] initWithTitle:@"Page View Controller" viewControllers:@[vc1,vc2,vc3,vc4,vc5]];
[self.navigationController pushViewController:pagevc animated:YES];
属性
/// 中间的view使用时直接赋值
@property (nonatomic, strong) UIView *middleView;
/// 底部的view使用时直接赋值
@property (nonatomic, strong) UIView *bottomView;
/// 当前页的索引
@property (nonatomic, assign) NSInteger displayIndex;
/// 当前显示的view
@property (nonatomic, strong) UIView *displayView;
@property (nonatomic, copy, readonly) NSArray *viewControllers;
/// 普通的颜色
@property (nonatomic, strong) UIColor *commonColor;
/// 选中的颜色
@property (nonatomic, strong) UIColor *selectColor;
/// title字体大小
@property (nonatomic, assign) CGFloat titleSize;
/// 选中的title放大倍数 (默认1)
@property (nonatomic, assign) CGFloat selectTitleZoomMultiple;
委托
@protocol DPPageViewControllerDelegate <NSObject>
@optional
- (void)pageViewController:(DPPageViewController *)pageViewController displayIndex:(NSInteger)index;
/**
自定义小title
*/
- (void)pageViewController:(DPPageViewController *)pageViewController titleItem:(UIButton *)item;
@end
更多
// move TopView
vc1.pageViewController = pagevc;
vc2.pageViewController = pagevc;
pagevc.itemHeight = 40;
pagevc.minItemWidth = 70;
pagevc.selectTitleZoomMultiple = 1.5;
pagevc.commonColor = [UIColor blueColor];
pagevc.selectColor = [UIColor redColor];
UIView *topView = [UIView new];
topView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 250);
UILabel *topLabel = [UILabel new];
topLabel.textAlignment = NSTextAlignmentCenter;
topLabel.text = @"Top View";
[topView addSubview:topLabel];
topLabel.frame = topView.bounds;
pagevc.topView = topView;
UIView *middleView = [UIView new];
middleView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50);
UILabel *middleLabel = [UILabel new];
middleLabel.textAlignment = NSTextAlignmentCenter;
middleLabel.text = @"Middle View";
[middleView addSubview:middleLabel];
middleLabel.frame = middleView.bounds;
pagevc.middleView = middleView;
UIView *bottomView = [UIView new];
bottomView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50);
UILabel *bottomLabel = [UILabel new];
bottomLabel.textAlignment = NSTextAlignmentCenter;
bottomLabel.text = @"Bottom View";
[bottomView addSubview:bottomLabel];
bottomLabel.frame = bottomView.bounds;
pagevc.bottomView = bottomView;
作者
dpwong, [email protected]
许可
DPPageViewController 在 MIT 许可下可用。更多信息请参阅 LICENSE 文件。