Coder Social home page Coder Social logo

jcyclepictureview's Introduction

Swift图片轮播 JCyclePictureView

用 UICollectionView 写的无限滚动轮播图,支持自定义 cell、滚动方向等。

License Platform

Issues

如果使用过程中,有什么问题欢迎issues。

Swift4

Swift4 及以上版本

CocoaPods

  • 支持CocoaPods
pod 'JCyclePictureView' 

Support

  • 支持纯图片
  • 支持文本图片结合
  • 支持横向滚动
  • 支持纵向滚动
  • 支持手势滑动
  • 支持点击回调
  • 支持图片数据的延时加载
  • 支持没有数据,占位图占位
  • 支持本地图片显示及与网络图的混合显示
  • 支持系统UIPageControl位置设置
  • 支持纯文本
  • 支持UIPageControl.currentPage图片修改样式

Usage

// 数据源
let pictures: [String] = ["http://pic29.nipic.com/20130512/12428836_110546647149_2.jpg", "picture2", "picture3", "picture4", "picture5", "http://pic29.nipic.com/20130512/12428836_110546647149_2.jpg", "picture7"]

// 初始化
let cyclePictureView: JCyclePictureView = JCyclePictureView(frame: CGRect(x: 0, y: 20, width: self.view.frame.width, height: 150), pictures: pictures)

// 标题
cyclePictureView.titles = ["标题1", "标题2", "标题3", "标题4", "标题5", "标题6", "标题7"]
         
// 滚动方向
cyclePictureView.direction = .left
        
// 自动滚动时间
cyclePictureView.autoScrollDelay = 3
        
// pageControl 位置
cyclePictureView.pageControlStyle = .center
        
// 默认显示图
cyclePictureView.placeholderImage = #imageLiteral(resourceName: "picture1")
        
// 高亮圆点
cyclePictureView.pageControl.currentPageIndicatorTintColor
cyclePictureView.pageControl.currentPageIndicatorImage
        
// 默认圆点
cyclePictureView.pageControl.pageIndicatorTintColor
cyclePictureView.pageControl.pageIndicatorImage

// 点击回调
cyclePictureView.didTapAtIndexHandle = { index in
            
    print("点击了第 \(index + 1) 张图片")
}
        
self.view.addSubview(cyclePictureView)

// 自定义 cell
cyclePictureView.register([CustomCell.self], identifiers: ["CustomCell"]) { (collectionView, indexPath, picture) -> UICollectionViewCell in
            
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CustomCell", for: indexPath) as! CustomCell
            
    if picture.hasPrefix("http") {
                
        cell.imageView.kf.setImage(with: URL(string: picture), placeholder: nil)
                
    } else {
                
        cell.imageView.image = UIImage(named: picture)
    }
            
    cell.label.text = "自定义 cell"
            
    cell.label.textColor = UIColor.white
            
    return cell
}
        
// 自定义 nib cell
cyclePictureView.register(<#T##nibs: [UINib?]##[UINib?]#>, identifiers: <#T##[String]#>, customCellHandle: <#T##JCyclePictureViewCustomCellHandle##JCyclePictureViewCustomCellHandle##(UICollectionView, IndexPath) -> UICollectionViewCell#>)

Example

示例代码见ViewController.swift

实现逻辑:http://www.jianshu.com/p/e13992f78aef

Author

Zebra,[email protected]

jcyclepictureview's People

Contributors

zebraciam avatar

Stargazers

UAN avatar  avatar  avatar  avatar  avatar  avatar  avatar speedx avatar  avatar Ryan avatar  avatar  avatar AlieZ avatar TTanys avatar Paak avatar Hang L avatar 尚光泉 avatar 孙琦 avatar 李连有 avatar  avatar  avatar  avatar DAO avatar  avatar Long avatar  avatar johnny ma avatar  avatar  avatar Hunter Zhang avatar XYZTech avatar  avatar MohsinAli avatar  avatar ZCC1 avatar  avatar  avatar

Watchers

James Cloos avatar MohsinAli avatar  avatar

jcyclepictureview's Issues

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.