UnlimitedCarousel 1.4.2

UnlimitedCarousel 1.4.2

Nathan 维护。



 
依赖关系
SDWebImage~> 4.0
SnapKit~> 3.0
 

  • 作者:
  • WhatTheNathan

UnlimitedCarousel

Version License Language Platform

用于 iOS 的 Swift 开发的自定义 Carousel 图形,高度可定制

概述

要求

  • iOS 9.0+
  • Xcode 9
  • Swift 3.2
  • SnapKit && SDWebImage

安装

CocoaPods

UnlimitedCarousel 通过 CocoaPods 提供。

在您的 Podfile 中添加 UnlimitedCarousel 的 pod 条目

pod 'UnlimitedCarousel'

将 InfiniteCarousel 安装到您的项目中

pod install

使用方法

您需要做的唯一事情是导入 UnlimitedCarousel,创建一个实例并将其通过代码或 StoryBoard 添加到您的 View 中,并遵循其数据源和代理。

import UnlimitedCarousel
let carousel = UnlimitedCarousel(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 160))
carousel.delegate = self
carousel.dataSource = self
self.view.addSubview(carousel)

只需实现 dataSource 和 delegate。

dataSource

注意:UnlimitedCarousel 中部分的数目是创建无限效果的关键,建议使用 3 或 5。.

extension ViewController: UnlimitedCarouselDataSource {
    func numberOfSections(in carousel: UnlimitedCarousel) -> Int {
        return 3
    }
    
    func numberOfFigures(for carousel: UnlimitedCarousel) -> Int {
        return itemArray.count
    }
    
    func titleForFigure(at indexPath: ICIndexPath, in carousel: UnlimitedCarousel) -> String {
        return itemArray[indexPath.row].title
    }
    
    func picLinkForFigure(at indexPath: ICIndexPath, in carousel: UnlimitedCarousel) -> URL {
        return URL(string: itemArray[indexPath.row].picture_url)!
    }
}

Delegate

extension ViewController: UnlimitedCarouselDelegate {
    func infiniteCarousel(_ carousel: UnlimitedCarousel, didSelectFigureAt indexPath: ICIndexPath) {
        let item = itemArray[indexPath.row]
        let url = item.link
        let webVC = WebViewController()
        webVC.webUrl = URL(string: url)
        webVC.navigationItem.title = item.title
        self.navigationController?.pushViewController(webVC, animated: true)
        }
    }
}

自定义

let carousel = UnlimitedCarousel(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 160))
carousel.pageControl.currentPageIndicatorTintColor = 
carousel.pageControl.tintColor = 
carousel.hidesForSinglePage = 

待办事项

  • 自定义的分页控件
  • 不再依赖于 SnapKitSDWebImage

变更日志

  • v1.4.0 稳定版本 1.0
  • v1.4.2 添加可选标题标签

联系信息

发送电子邮件至: @NathanLiu

许可协议

UnlimitedCarousel 采用 BSD 2-Clause "Simplified" License 发布。详情见 LICENSE 文件。