Latest 1.0.1
License MIT
Platforms ios 8.0
Frameworks UIKit

ImageCarouselView 是一个用Swift3实现的图片轮播控件

  • 不依赖任何第三方类库
  • 代码简洁,使用简单


alt tag


  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3.0+



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build ImageCarouselView.

To integrate SnapKit into your Xcode project using CocoaPods, specify it in your Podfile:

source ''
platform :ios, '8.0'

target '<Your Target Name>' do
    pod 'ImageCarouselView'

Then, run the following command:

$ pod install


If you prefer not to use either of the aforementioned dependency managers, you can integrate ImageCarouselView into your project manually.


Quick Start

import ImageCarouselView

class MyViewController: UIViewController {

    lazy var imageCarouselView: ImageCarouselView = {
        let screenWidth = UIScreen.main.bounds.size.width
        let frame = CGRect(x: 0, y: 0, width: screenWidth, height: screenWidth*320/568)

        let images = [["url": "", "tit": "Whatever is worth doing is worth doing well."],
        ["url": "", "tit": "You may be out of my sight, but never out of my mind."],
        ["url": "", "tit": "When the whole world is about to rain, let’s make it clear in our heart together."],
        ["url": "", "tit": "I’ll think of you every step of the way."],
        ["url": "", "tit": "Love is not a maybe thing. You know when you love someone."]]
        let carouselView = ImageCarouselView(frame: frame, imageArray: images)
        carouselView.delegate = self
        carouselView.isAutoScroll = true
        //carouselView.scrollInterval = 2
        //carouselView.isShowImageText = false

        return carouselView

    override func viewDidLoad() {



extension ViewController: ImageCarouselViewDelegate {
        func imageCarouselView(_ imageCarouselView: ImageCarouselView, didSelectItemAt index:Int) {
            //self.toast(message: "touched the (index) index image")
        // 设置网络图的方法(这里将图片设置方法交给代理,避免本控件依赖网络库)
        func setImageForImageView(imageV: UIImageView, byUrlString: String?, placeholderImage:UIImage?){
            imageV.contentMode = UIViewContentMode.scaleAspectFill
            imageV.setImageWith(URL(string: byUrlString!)!, placeholderImage: placeholderImage)
        // 取出图片数据里面的文本字段值
        func titleForData(_ imageData:Any) -> String {
            let data = imageData as? Dictionary<String, String>
            return data!["tit"]!
        // 取出图片数据里面的图片Url字段值
        func imageUrlStringForData(_ imageData:Any) -> String {
            let data = imageData as? Dictionary<String, String>
            return data!["url"]!


ImageCarouselView is released under the MIT license. See LICENSE for details.

Latest podspec

    "name": "ImageCarouselView",
    "version": "1.0.1",
    "summary": "swift3 u5c01u88c5u7684u56feu7247u8f6eu64adu63a7u4ef6, u4e0du4f9du8d56u4efbu4f55u7b2cu4e09u65b9u5e93",
    "description": "swift3 u5c01u88c5u7684u56feu7247u8f6eu64adu63a7u4ef6, u4f18u70b9uff1au4ee3u7801u7b80u4ecbuff0cu4e0du4f9du8d56u4efbu4f55u7b2cu4e09u65b9u5e93",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "GTMYang": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.1"
    "source_files": "Sources/*.{h,swift}",
    "platforms": {
        "ios": "8.0"
    "frameworks": "UIKit",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This