项目介绍:
JLAdvertisingScrollView
轻量级的广告轮播滚动视图,支持网络图片,支持自动翻页,支持无限循环,支持手势滑动,支持点击事件,简单配置,快速集成
github托管地址)
如何安装
1 手动安装
step1:将项目JLAdvertisingScrollView/Source 文件夹中的文件直接拖入你的项目中即可
step2:导入.h文件
#import “JLAdvertisingScrollView.h”
2 CocoaPods
step1: add the following line to your Podfile:
pod ‘JLAdvertisingScrollView’,’~> 0.0.1′
step2: 导入.h文件
#import <JLAdvertisingScrollView/JLAdvertisingScrollView.h>
使用示例
JLAdvertisingScrollView *advertising = [[JLAdvertisingScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 280)];
//[advertising setImageNames:@[@"便利店",@"服务",@"教育",@"美食"]];
//[advertising setImages:@[[UIImage imageNamed:@"便利店"],[UIImage imageNamed:@"服务"],[UIImage imageNamed:@"教育"],[UIImage imageNamed:@"美食"]]];
[advertising setImageUrls:@[@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489748993156&di=a05dd001db70790ff1d6d8376cf8a5d6&imgtype=0&src=http%3A%2F%2Fimg5.hao123.com%2Fdata%2F1_08df73b69519276be6e4d5e0c442ae9e_510",@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489748993155&di=fba9f631aebbe0eee97928191814f6ab&imgtype=0&src=http%3A%2F%2Fimg6.web07.cn%2FUPics%2FBizhi%2F2016%2F0913%2F121474130955191.jpg",@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489748993155&di=d2c9c25987a73fe686254a05c56bedf3&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fc%2F57849d650ef11.jpg",@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489748993155&di=eb747546ee08dfd0b995f5c2f8642864&imgtype=0&src=http%3A%2F%2Fimg.tuku.cn%2Ffile_big%2F201502%2F0e93d8ab02314174a933b5f00438d357.jpg",@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489748993154&di=03aa60ead6f966cad7e0c78ecb3f449e&imgtype=0&src=http%3A%2F%2Fpic.58pic.com%2F58pic%2F17%2F14%2F25%2F43Y58PICfJB_1024.jpg"]];
[advertising setDelegate:self];
[advertising setAutoLoopInterval:3];
[self.view addSubview:advertising];
代码说明
@protocol JLAdvertisingScrollViewDelegate <NSObject>
@optional
/**
点击事件代理
@param scrollView JLAdvertisingScrollView
@param index 被点击的图片的序号
*/
- (void)advertisingScrollView:(JLAdvertisingScrollView *)scrollView clickEventAtIndex:(NSInteger)index;
@end
@interface JLAdvertisingScrollView : UIView
@property (strong, nonatomic) id <JLAdvertisingScrollViewDelegate> delegate;
/**
图像占位符
*/
@property (strong, nonatomic) UIImage *placeholderImage;
/**
使用本地图片初始化
*/
@property (strong, nonatomic) NSArray <UIImage *> *images;
/**
使用本地图片的名称初始化
*/
@property (strong, nonatomic) NSArray <NSString *> *imageNames;
/**
使用网络图片的URL地址初始化
*/
@property (strong, nonatomic) NSArray <NSString *> *imageUrls;
/**
广告滚动视图是否自动滚动,默认为YES
*/
@property (assign, nonatomic) BOOL autoLoop;
/**
广告滚动视图自动滚动的时间间隔
*/
@property (assign, nonatomic) NSTimeInterval autoLoopInterval;
@end
github地址:
https://github.com/liujing0735/JLAdvertisingScrollView