首先導(dǎo)入#import "YZCycleScrollView.h"文件
接線來(lái)賦值下面代碼就行啦 即可實(shí)現(xiàn)自動(dòng)滾動(dòng)
#import "ViewController.h"
#import "YZCycleScrollView.h"
@interface ViewController ()<YZCycleScrollViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor magentaColor];
//每頁(yè)的標(biāo)題
NSArray *titles = @[@"騰訊", @"京東", @"阿里巴巴", @"小米"];
//圖片的連接
NSArray *images = @[@"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=624026161,316177573&fm=27&gp=0.jpg", @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1508935179522&di=0b13b5528b6cd4c28093e373a9162b69&imgtype=0&src=http%3A%2F%2Fpic22.nipic.com%2F20120711%2F9782298_190753257000_2.jpg", @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1508935202373&di=d9198e986b6e61f6294114718cca679a&imgtype=0&src=http%3A%2F%2Fpic2.ooopic.com%2F10%2F60%2F11%2F96b1OOOPIC8f.jpg", @"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3846820649,3284377375&fm=27&gp=0.jpg"];
//每頁(yè)的網(wǎng)址
NSArray *urls = @[@"http://www.qq.com", @"http://www.jd.com", @"http://www.taobao.com", @"http://www.xiaomi.com"];
//設(shè)置滾動(dòng)樣式
YZCycleScrollView *cycleScrollView = [[YZCycleScrollView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height/4) titles:titles images:images urls:urls autoPlay:YES delay:3.0f];
//設(shè)置代理
cycleScrollView.delegate = self;
//添加試圖
[self.view addSubview:cycleScrollView];
}