[控件分享] ZYBannerView

2016-09-05 09:41:45 +08:00
 kengsir

DEMO 下载: http://code4app.com/forum.php?mod=viewthread&tid=10390&extra=page%3D3%26filter%3Dsortid%26orderby%3Ddateline%26sortid%3D1

     

ZYBannerView

Features

Usage

Basic Usage

只需简单的 2 步即可快速集成此控件

1.创建 Banner 并设置数据源

self.banner = [[ZYBannerView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
self.banner.dataSource = self;
[self.view addSubview:self.banner];

2.实现数据源方法

// 返回 Banner 需要显示 Item(View)的个数
- (NSInteger)numberOfItemsInBanner:(ZYBannerView *)banner
{
    return 3;
}

// 返回 Banner 在不同的 index 所要显示的 View
- (UIView *)banner:(ZYBannerView *)banner viewForItemAtIndex:(NSInteger)index
{
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xxx"]];
    return imageView;
}

Advanced Usage

各种属性与方法的介绍

Property

@property (nonatomic, assign) IBInspectable BOOL shouldLoop;
@property (nonatomic, assign) IBInspectable BOOL showFooter;
@property (nonatomic, assign) IBInspectable BOOL autoScroll;
@property (nonatomic, assign) IBInspectable NSTimeInterval scrollInterval;
@property (nonatomic, strong, readonly) UIPageControl *pageControl;
@property (nonatomic, assign, readwrite)  CGRect pageControlFrame;
@property (nonatomic, weak) IBOutlet id<ZYBannerViewDataSource> dataSource;
@property (nonatomic, weak) IBOutlet id<ZYBannerViewDelegate> delegate;

NOTE : shouldLoop, showFooter, autoScroll, scrollInterval, dataSource, delegate 均可支持在 Storyboard\xib 中直接设置

Method

- (void)reloadData;
- (void)startTimer;
- (void)stopTimer;

DataSource

- (NSInteger)numberOfItemsInBanner:(ZYBannerView *)banner;
- (UIView *)banner:(ZYBannerView *)banner viewForItemAtIndex:(NSInteger)index;
- (NSString *)banner:(ZYBannerView *)banner titleForFooterWithState:(ZYBannerFooterState)footerState;

Delegate

- (void)banner:(ZYBannerView *)banner didSelectItemAtIndex:(NSInteger)index;
- (void)bannerFooterDidTrigger:(ZYBannerView *)banner;

Requirements

Installation

1.使用 CocoaPods:

pod 'ZYBannerView'

2.手动添加:

License

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

1980 次点击
所在节点    分享创造
2 条回复
ljcarsenal
2016-09-05 13:50:20 +08:00
我猜 zy 是你名字?不过 ios 的开源库似乎用作者名字起名是很普遍的现象?
kengsir
2016-09-05 13:59:34 +08:00
原作者或者 github 地址可以前往原链接查询到~~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/303935

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX