Git Product home page Git Product logo

zjscrollpageview's Introduction

ZJScrollPageView

####OC版的简单方便的集成网易新闻, 腾讯视频, 头条 等首页的滑块视图联动的效果, segmentVIew, scrollViewController

###swift版本的请点这里

####注意,如果您需要查看详细的注释, 可以下载swift版本里面, 这里很多地方就没有把注释移过来了

##使用示例效果 滚动示例1.gif滚动示例2.gif滚动示例3.gif

滚动示例4.gif滚动示例5.gif滚动示例6.gif

滚动示例7.gif 滚动示例8.gif


可以简单快速灵活的实现上图中的效果


书写思路移步

###简书1

Requirements

  • iOS 7.0+

Installation

###直接将下载文件的ZJScrollPageView文件夹下的文件拖进您的项目中然后#import "ZJScrollPageView.h"就可以使用了

##usage

####一. 使用ScrollPageView , 提供了各种效果的组合,但是不能修改segmentView和ContentView的相对位置,两者是结合在一起的

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"效果示例";
//1.必要的设置, 如果没有设置可能导致内容显示不正常
self.automaticallyAdjustsScrollViewInsets = NO;
// 2.设置需要的效果分类
ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
// 缩放标题
style.scaleTitle = YES;
// 颜色渐变
style.gradualChangeTitleColor = YES;
// 3.设置子控制器 --- 注意子控制器需要设置title, 将用于对应的tag显示title
NSArray *childVcs = [NSArray arrayWithArray:[self setupChildVcAndTitle]];
// 4.初始化
ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 64.0, self.view.bounds.size.width, self.view.bounds.size.height - 64.0) segmentStyle:style childVcs:childVcs parentViewController:self];
// 5. 添加scrollPageView
[self.view addSubview:scrollPageView];

}

####二 使用 ZJScrollSegmentView 和 ZJContentView, 提供相同的效果组合, 但是同时可以分离开segmentView和contentView,可以单独设置他们的frame, 使用更灵活

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"效果示例";

//必要的设置, 如果没有设置可能导致内容显示不正常
self.automaticallyAdjustsScrollViewInsets = NO;
[self setupSegmentView];
[self setupContentView];

}

###setupSegmentView // 注意: 一定要避免循环引用!! __weak typeof(self) weakSelf = self; ZJScrollSegmentView *segment = [[ZJScrollSegmentView alloc] initWithFrame:CGRectMake(0, 64.0, 160.0, 28.0) segmentStyle:style titles:titles titleDidClick:^(UILabel *label, NSInteger index) {

    [weakSelf.contentView setContentOffSet:CGPointMake(weakSelf.contentView.bounds.size.width * index, 0.0) animated:YES];
    
}];
// 自定义标题的样式
segment.layer.cornerRadius = 14.0;
segment.backgroundColor = [UIColor redColor];
// 当然推荐直接设置背景图片的方式
//    segment.backgroundImage = [UIImage imageNamed:@"extraBtnBackgroundImage"];

self.segmentView = segment;
self.navigationItem.titleView = self.segmentView;

###setupContentView

    NSArray *childVcs = [self setupChildVcAndTitle];
ZJContentView *content = [[ZJContentView alloc] initWithFrame:CGRectMake(0.0, 64.0, self.view.bounds.size.width, self.view.bounds.size.height - 64.0) childVcs:childVcs segmentView:self.segmentView parentViewController:self];
self.contentView = content;
[self.view addSubview:self.contentView];

###如果您在使用过程中遇到问题, 请联系我 ####QQ:854136959 邮箱: [email protected] ####如果对您有帮助,请随手给个star鼓励一下

License

ScrollPageView is released under the MIT license. See LICENSE for details.

zjscrollpageview's People

Contributors

jasnig avatar

Watchers

@FelixMLians avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.