仿制网易新闻左右滑动页面切换效果

2017-12-18  本文已影响0人  你猜我猜不猜你猜我猜不猜

DPPageViewController

git:https://github.com/DaoPinWong/DPPageViewController

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

DPPageViewController is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "DPPageViewController"

Usage

Quick to use

#import "DPPageViewController.h"


DPPageViewController *pagevc = [[DPPageViewController alloc] initWithTitle:@"Page View Controller" viewControllers:@[vc1,vc2,vc3,vc4,vc5]];
[self.navigationController pushViewController:pagevc animated:YES];


2017-02-15 15_58_51.gif

property


/// 中间的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;

More


    pagevc.itemHeight = 40;
    pagevc.minItemWidth = 70;
    pagevc.selectTitleZoomMultiple = 1.5;
    pagevc.commonColor = [UIColor blueColor];
    pagevc.selectColor = [UIColor redColor];
    
    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;
2017-02-15 16_32_29.gif

Author

dpwong, 413655409@qq.com

License

DPPageViewController is available under the MIT license. See the LICENSE file for more info.

上一篇 下一篇

猜你喜欢

热点阅读