Giter Club home page Giter Club logo

zcautoscrollview's Introduction

ZCAutoScrollView

简单易用的广告轮播页面,可轮播本地和网络图片(依赖SDWebImage),支持手动和自动滚动,可设置小圆点位置和网络缺省图片。支持图片的点击事件。

效果

动态图片展示不出来的这里我直接附上图片地址 http://7xt7mf.com1.z0.glb.clouddn.com/%E6%8F%90%E7%A4%BA%E6%A1%86.gif 演示效果

原理

采用UIScrollView完成,假如要循环3张图片,则放4张,也就是最后一张图片放2次。顺序为3123,默认scrollView在第一张图片上,当切换到第三张时把scrollView的偏移量移到第一张图片上,这样就完成了循环。

用法

1.支持CocoaPods,

platform :ios, '7.0'
use_frameworks!
pod 'ZCAutoScrollView', '~> 0.0.2'

2.把ZCAutoScrollView这个文件夹拖入工程,文件夹里面包含SDWebImage和ZCAutoScrollView.h,ZCAutoScrollView.m两个文件,若项目中已有SDWebImage,只需把其余两个文件拖入工程。 导入头文件#import "ZCAutoScrollView.h"

 ZCAutoScrollView *scrollView = [[ZCAutoScrollView alloc]initWithFrame:CGRectMake(0, 100, KWIDTH, 400)];
    scrollView.imageArray = @[@"001.jpg",@"002.jpg",@"003.jpg",@"http://pic1.nipic.com/2008-12-25/2008122510134038_2.jpg"];
    scrollView.placeholderImage = [UIImage imageNamed:@"dog_1"]; //设置缺省图片
    scrollView.pageControlAliment = NSPageControlAlimentCenter; //设置小圆点居中,默认不显示
    // 图片的点击方法
    [scrollView addTapClick:^(NSInteger index) {
        NSLog(@"我是第%ld张图片",index);
    }];
    [self.view addSubview:scrollView];

说明

本demo用时较短,借鉴了前辈的轮子。疏漏之处在所难免,觉得有那么一点点用的请star一下,觉得不好的请直接请批评指正。

邮箱:[email protected]

zcautoscrollview's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.