• iOS实现图片无限轮播之使用第三方库SDCycleScrollView(转)


    下载链接:github不断更新地址:https://github.com/gsdios/SDCycleScrollView

    #import "ViewController.h"

    #import "SDCycleScrollView.h"

    @interface ViewController () <</span>SDCycleScrollViewDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        self.view.backgroundColor = [UIColor colorWithRed:0.98green:0.98 blue:0.98 alpha:0.99];

    UIImageView *backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"005.jpg"]];

    frame = self.view.bounds;

    self.view addSubview:backgroundView];

        

        // 情景一:采用本地图片实现

    NSArray *images = @[[UIImage imageNamed:@"h1.jpg"],

    UIImage imageNamed:@"h2.jpg"],

    UIImage imageNamed:@"h3.jpg"],

    UIImage imageNamed:@"h4.jpg"]

    ];

        

        // 情景二:采用网络图片实现

    NSArray *imagesURLStrings = @[

                               @"https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf=425,260,50/sign=a4b3d7085dee3d6d2293d48b252b5910/0e2442a7d933c89524cd5cd4d51373f0830200ea.jpg",

                               @"https://ss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/super/whfpf=425,260,50/sign=a41eb338dd33c895a62bcb3bb72e47c2/5fdf8db1cb134954a2192ccb524e9258d1094a1e.jpg",

                              @"http://c.hiphotos.baidu.com/image/w=400/sign=c2318ff84334970a4773112fa5c8d1c0/b7fd5266d0160924c1fae5ccd60735fae7cd340d.jpg"

    ];

        

        // 情景三:图片配文字

    NSArray *titles = @[@"感谢您的支持,如果下载的",

    @"如果代码在使用过程中出现问题",

    @"您可以发邮件到gsdios@126.com",

    @"感谢您的支持"

    ];

        

        

        

        

        CGFloat w = self.view.bounds.size.width;

        

        // 本地加载 --- 创建不带标题的图片轮播器

    SDCycleScrollView *cycleScrollView = [SDCycleScrollViewcycleScrollViewWithFrame:CGRectMake(0, 100, w, 180)imagesGroup:images];

        cycleScrollView.infiniteLoop = YES;

    delegate = self;

        cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;

    self.view addSubview:cycleScrollView];

        //         --- 轮播时间间隔,默认1.0秒,可自定义

        //cycleScrollView.autoScrollTimeInterval = 4.0;

        

        

         //网络加载 --- 创建带标题的图片轮播器

        SDCycleScrollView *cycleScrollView2 = [SDCycleScrollViewcycleScrollViewWithFrame:CGRectMake(0320, w, 180)imageURLStringsGroup:nil]; // 模拟网络延时情景

        cycleScrollView2.pageControlAliment =SDCycleScrollViewPageContolAlimentRight;

    delegate = self;

    titlesGroup = titles;

    dotColor = [UIColor yellowColor]; // 自定义分页控件小圆标颜色

    placeholderImage = [UIImageimageNamed:@"placeholder"];

    self.view addSubview:cycleScrollView2];

        

    模拟加载延迟

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    imageURLStringsGroup = imagesURLStrings;

        });

        

        // 清除缓存

    //    [cycleScrollView2 clearCache];

        

    }



    void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index

        NSLog(@"---点击了第%ld张图片", index);


     

    @end

  • 相关阅读:
    JS函数节流
    JS中多种方式创建对象
    javascript的几种继承
    多进程基本概念
    APUE(1)——UNIX基本概念
    pthread
    使用TortoiseGit,设置ssh方式连接git仓库。
    mac系统下用ssh方式连接git仓库
    webstorm2017.02版本如何使用material theme
    谷歌浏览器的字体问题
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5405645.html
Copyright © 2020-2023  润新知