VGParallaxHeader 0.0.6

VGParallaxHeader 0.0.6

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

Marek Serafin 维护。



  • 作者
  • Marek Serafin

Parallax Header 类(UIScrollView/UITableView 类别)可以与所有类型的 Table Views 和 Scroll Views 一起使用,同时使用 Auto Layout。

它使用 tableHeaderView 因此不需要通过向 UITableView 添加子视图并更改 contentInset 来进行恶意的操作。如果您更改 contentInset,则部分标题会显示错误。而且 YES ... 它非常快;)

最好的方法是下载示例项目并尝试使用它来探索所有配置。

演示 GIF

https://raw.githubusercontent.com/stoprocent/VGParallaxHeader/master/demo.gif

安装

您可以使用 CocoaPods。

pod 'VGParallaxHeader'

版本 0.0.6 更新

此版本修复了我在 VGParallaxHeaderModeCenter 模式下没有注意到的一个小错误,当视差标题视图高度将跳到 0.0f-0.5f 时,这会导致在每个 scrollViewDidScroll 上调用 layoutSubviews。

**请注意,VGParallaxHeaderModeCenter 应该是最快模式。**

**我认为我差不多快要将其标记为 1.0 版本了。如果您有任何请求或想法,请告知我。**

版本 0.0.5 更新

请注意,阴影现在已被弃用。如果您使用 setParallaxHeaderView:mode:height:shadowBehaviour:,它将给出警告。

新版本引入了一个名为 Sticky View 的新属性。您可以使用它来模拟阴影。在示例和 gif 中查看吧:) 欢迎使用新版本,如果在 Github issues 中遇到任何问题,请报告。仍需等待完整 Storyboard 支持,我非常希望有人能创建具有此功能的 pull request。

使用 VGParallaxheader

导入 UIScrollView+VGParallaxHeader.h,并按以下方式使用

- (void)viewDidLoad {
    [super viewDidLoad];

    HeaderView *headerView = [HeaderView alloc] init];

    // or self.tableView
    [self.scrollView setParallaxHeaderView:headerView
                                      mode:VGParallaxHeaderModeFill // For more modes have a look in UIScrollView+VGParallaxHeader.h 
                                    height:200];

    // Optional Sticky View :)
    UILabel *stickyLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    stickyLabel.backgroundColor = [UIColor colorWithRed:1 green:0.749 blue:0.976 alpha:1];
    stickyLabel.textAlignment = NSTextAlignmentCenter;
    stickyLabel.text = @"Say hello to Sticky View :)";

    self.tableView.parallaxHeader.stickyViewPosition = VGParallaxHeaderStickyViewPositionBottom; // VGParallaxHeaderStickyViewPositionTop
    [self.tableView.parallaxHeader setStickyView:stickyLabel
                                      withHeight:40];
}

#pragma mark - UIScrollView Delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    // This must be called in order to work
    [self.scrollView shouldPositionParallaxHeader];

    // scrollView.parallaxHeader.progress - is progress of current scroll
    NSLog(@"Progress: %f", scrollView.parallaxHeader.progress);

    // This is how you can implement appearing or disappearing of sticky view
    [scrollView.parallaxHeader.stickyView setAlpha:scrollView.parallaxHeader.progress];
}