CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Nov 2017 |
Maintained by Zhangweifan.
只需简单的2步即可快速集成此控件
self.banner = [[ZYBannerView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
self.banner.dataSource = self;
[self.view addSubview:self.banner];// 返回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;
}各种属性与方法的介绍
NO@property (nonatomic, assign) IBInspectable BOOL shouldLoop;NO (此属性为YES时, shouldLoop属性会被置为NO)@property (nonatomic, assign) IBInspectable BOOL showFooter;NO@property (nonatomic, assign) IBInspectable BOOL autoScroll;@property (nonatomic, assign) IBInspectable NSTimeInterval scrollInterval;pageIndicatorTintColor, currentPageIndicatorTintColor@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中直接设置
- (void)reloadData;viewWillAppear:和viewWillDisappear:中分别调用这两个方法, 使得Banner没有显示的时候定时器不会一直占用着资源.- (void)startTimer;
- (void)stopTimer;- (NSInteger)numberOfItemsInBanner:(ZYBannerView *)banner;index所要显示的View. 这个View可以是简单的一个UIImageView, 也可以是自定义的一个复杂的View. View的大小自动布局为Banner的大小, 无需对此View设置frame 【required】- (UIView *)banner:(ZYBannerView *)banner viewForItemAtIndex:(NSInteger)index;ZYBannerFooterStateIdle正常状态 \ ZYBannerFooterStateTrigger触发状态)显示的文字【optional】- (NSString *)banner:(ZYBannerView *)banner titleForFooterWithState:(ZYBannerFooterState)footerState;index个Item时, 此代理方法将被调用 【optional】- (void)banner:(ZYBannerView *)banner didSelectItemAtIndex:(NSInteger)index;- (void)bannerFooterDidTrigger:(ZYBannerView *)banner;1.使用CocoaPods:
pod 'ZYBannerView'2.手动添加:
#import "ZYBannerView.h"ZYBannerView is released under the MIT license. See LICENSE for details.