只需简单的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;
}
各种属性与方法的介绍
@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;
注意: shouldLoop, showFooter, autoScroll, scrollInterval, dataSource, delegate 均可支持在 Storyboard/xib 中直接设置
- (void)reloadData;
- (void)startTimer;
- (void)stopTimer;
- (NSInteger)numberOfItemsInBanner:(ZYBannerView *)banner;
- (UIView *)banner:(ZYBannerView *)banner viewForItemAtIndex:(NSInteger)index;
ZYBannerFooterStateIdle
正常状态 \ ZYBannerFooterStateTrigger
触发状态)显示的文字 【可选】- (NSString *)banner:(ZYBannerView *)banner titleForFooterWithState:(ZYBannerFooterState)footerState;
- (void)banner:(ZYBannerView *)banner didSelectItemAtIndex:(NSInteger)index;
- (void)bannerFooterDidTrigger:(ZYBannerView *)banner;
1.使用 CocoaPods
pod 'ZYBannerView'
2.手动添加
#import "ZYBannerView.h"
ZYBannerView 采用 MIT 许可证发布。详情见 LICENSE。