zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    img标签中alt属性与title属性在seo的作用-摘自网友
    C# 从补码中获取有符号数的实际数值
    you need to load the kernel first
    桌面远程访问
    供应商通过向日葵访问公司外网办公电脑,通过办公电脑访问内网内生产用电脑
    配置交换机口可以上外网
    抠图和不失真的改变图形大小
    用机房现有双网口电脑添加监控
    服务器配置IP
    在DELL服务器上安装windows2012 r2服务器系统
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5405645.html
Copyright © 2011-2022 走看看