APParallaxHeader-Width 0.1.8

APParallaxHeader-Width 0.1.8

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年4月

Brandon Shelley 维护。



  • Mathias Amnell 和 Brandon Shelley

APParallaxHeader

此类别使您能够轻松添加一个透视式头部视图到您的滚动视图。其他替代方案需要通过继承 UIScrollViewUITableViewControllerUITableView。相反,APParallaxHeader 使用 Objective-C 运行时将以下两个方法添加到 UIScrollView,而无需进行任何子类化。

- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow;
- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height;
- (void)addParallaxWithView:(UIView*)view andHeight:(CGFloat)height;

示例

Demo

安装

手动安装

重要提示:如果您的项目没有使用 ARC-fobjc-arc 添加到目标设置 > 构建阶段 > 编译源中的 UIScrollView+ APParallaxHeader.m

  • APParallaxHeader/APParallaxHeader 文件夹拖入您的项目。
  • 在您需要的地方导入 UIScrollView+APParallaxHeader.h

使用方法

(请参阅 /Demo 中的示例 Xcode 项目)

添加透视图像

[tableView addParallaxWithImage:[UIImage imageNamed:@"ImageName"] andHeight:160];

添加透视自定义视图

注意:在添加自定义视图时,请使用 APParallaxViewDelegate、自动布局约束或 contentMode 来在滚动期间调整自定义视图的大小。

UIView *customView = [[UIView alloc] init];
[customView setFrame:CGRectMake(0, 0, 320, 160)];
[self.tableView addParallaxWithView:customView andHeight:160];

[self.tableView.parallaxView setDelegate:self];

APParallaxViewDelegate

APParallaxViewDelegate 会通知代理有关透视视图的调整大小。

方法

  • - (void)parallaxView:(APParallaxView *)view willChangeFrame:(CGRect)frame
  • - (void)parallaxView:(APParallaxView *)view didChangeFrame:(CGRect)frame

待办事项

  • 自定义影子的形状、不透明度、颜色等。
  • 设置最小高度
  • 设置图像视图的内容模式

已知问题

  • 使用样式的表格视图部分头部在滚动期间无法如预期地固定。

变更日志

0.1.6

  • 重新添加/修复可选阴影实现

0.1.5

  • 为 APParallaxView 调整大小添加委托回调(APParallaxViewDelegate)。

0.1.4

  • 带有或没有内阴影的初始化能力。
  • 能够将自定义视图作为透视视图。

0.1.3

  • 添加了内阴影

0.1.2

  • 初版发布

致谢

APParallaxHeader 是由 Mathias Amnell 在 Apping AB 创建的。代码灵感来源于 Sam Vermette 的作品 SVPullToRefresh(特别是使用 objc/runtime.h 来实现,无需子类化,使得实现变得非常简单)。

许可证

APParallaxHeader 以 MIT 许可证提供。有关更多信息,请参阅 LICENSE 文件。