JMParallaxView 0.1.1

JMParallaxView 0.1.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年11月

Joel Márquez 管理。



示例

要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install

要求

安装

JMParallaxView 是通过 CocoaPods 提供的。要安装它,只需将以下行添加到您的 Podfile 中

pod "JMParallaxView"

使用方法

简单头部

1. 创建一个 tableView
self.tableView = [UITableView new];
2. 创建一个头部
self.parallaxHeader = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"header1"]];
self.parallaxHeader.frame = CGRectMake(0, 0, CGRectGetWidth([UIScreen mainScreen].bounds), 200);
self.parallaxHeader.contentMode = UIViewContentModeScaleAspectFill;
self.parallaxHeader.clipsToBounds = YES;
3. 创建一个 JMParallaxView
self.parallaxView = [JMParallaxView new];
self.parallaxView.delegate = self;
self.parallaxView.headerTintColor = [UIColor whiteColor];
[self.view addSubview:self.parallaxView];
[self.parallaxView mas_updateConstraints:^(MASConstraintMaker *make) {
    make.edges.equalTo(self.view);
}];
4. 创建一个视觉差内容视图
self.parallaxContentView = [UIView new];
[self.parallaxContentView addSubview:self.tableView];
[self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
    make.edges.equalTo(self.parallaxContentView);
}];
5. 将所有组件组合在一起
[self.parallaxView addScrollView:self.tableView];
self.parallaxView.mainView = self.parallaxContentView;
self.parallaxView.headerView = self.parallaxHeader;
6. 享用

enjoy

带有粘性视图的头部

按照之前的所有步骤进行,在最后一步中,添加以下行

UILabel *stickyLabel = [[UILabel alloc] initWithFrame:
                        CGRectMake(0, 0, CGRectGetWidth([UIScreen mainScreen].bounds), 60)];
stickyLabel.text = @"I'm a sticky label!";
stickyLabel.backgroundColor = [UIColor orangeColor];
stickyLabel.textAlignment = NSTextAlignmentCenter;

self.parallaxView.stickyView = stickyLabel;
哇!

enjoy

作者

Joel Marquez,[email protected]

许可证

JMParallaxView 可以根据 MIT 许可证使用。有关更多信息,请参阅 LICENSE 文件。