iOS - 自动滚动

首先导入#import "YZCycleScrollView.h"文件
接线来赋值下面代码就行啦 即可实现自动滚动

#import "ViewController.h"
#import "YZCycleScrollView.h"

@interface ViewController ()<YZCycleScrollViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor magentaColor];
    //每页的标题
    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"];
    //每页的网址
    NSArray *urls = @[@"http://www.qq.com", @"http://www.jd.com", @"http://www.taobao.com", @"http://www.xiaomi.com"];
    //设置滚动样式
    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];
//设置代理
    cycleScrollView.delegate = self;
//添加试图
    [self.view addSubview:cycleScrollView];
    
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。