PWParallaxScrollView 1.2.0

PWParallaxScrollView 1.2.0

测试已测试
语言 Obj-CObjective C
许可证 MIT
发行上次发布2016年2月

Pin Shih Wang 维护。




  • 作者:
  • wpsteak

PWParallaxScrollView 是一个受 WWF 应用程序启发的,用于创建带缩放效果的滑动菜单的库

用法

导入头文件
#import "PWParallaxScrollView.h"
遵循 PWParallaxScrollViewDataSource 协议
@interface ViewController <PWParallaxScrollViewDataSource>
实现 PWParallaxScrollViewDataSource 方法
- (NSInteger)numberOfItemsInScrollView:(PWParallaxScrollView *)scrollView;
- (UIView *)backgroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;

设置 ForegroundScreenEdgeInsets

关于 ForegroundScreenEdgeInsets

自定义您的缩放偏移

foregroundScreenEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 100);

示例代码
    self.scrollView = [[PWParallaxScrollView alloc] initWithFrame:self.view.bounds];
    _scrollView.foregroundScreenEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 100);
    [self.view insertSubview:_scrollView atIndex:0];

- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 300, 70)];

    ...

    return label;
}

常规

foregroundScreenEdgeInsets = UIEdgeInsetsZero;

示例代码
    self.scrollView = [[PWParallaxScrollView alloc] initWithFrame:self.view.bounds];
    _scrollView.foregroundScreenEdgeInsets = UIEdgeInsetsZero;
    [self.view insertSubview:_scrollView atIndex:0];

- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 300, 70)];

    ...

    return label;
}

触测

- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 300, 70)];
    ...

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    ...
    [button addTarget:self action:@selector(test) forControlEvents:UIControlEventTouchUpInside];
    ...
    [label addSubview:button];

    return label;
}

moveToIndex , prev , next

示例代码
    [scrollView moveToIndex:3];
    [scrollView prevItem];
    [scrollView nextItem];

只有背景视图

只需不实现 foregroundViewAtIndex:scrollView: 方法(或返回 nil)
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;


变更日志 1.2.0

  • 添加 Swift 版本

感谢贡献

  • @yume190

变更日志 1.1.5

添加委托以接收 touchScrollViewTapped 事件

- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didRecieveTapAtIndex:(NSInteger)index;

感谢贡献

  • @Morgan-Kennedy

变更日志 1.1.0

  • 添加界面构建器支持(initWithCoder,Outlets)

  • 添加 PWParallaxDelegate 并提供检查当前索引是否变化的方法

感谢贡献

  • @matibot

MIT 许可证

PWParallaxScrollView 在 MIT 许可证下发布(请参阅许可证文件)

联系

有任何建议或改进之处?

请随时联系我

[email protected]