AACarousel 1.1.1

AACarousel 1.1.1

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最新发布2018年9月
SPM支持 SPM

ALAN881 维护。



  • Alan

AACarousel

Carthage Compatible

在 Swift 中轻松创建图片滑动器

特性

  • 纯 Swift 4.2 代码
  • 类是自定义 UIView,不是 UIPageViewController
  • 您可以使用 iOS 原生 SDK 或其他 3rd SDK 下载图片
  • 要求 iOS 8 或更高版本

样式一

风格二

安装

CocoaPods

AACarousel可以通过CocoaPods获得。

简单地将AACarousel添加到您的Podfile中。

pod 'AACarousel'

在终端中输入指令。

pod install

Carthage

AACarousel可以通过Carthage获得。

简单地将AACarousel添加到您的Cartfile中。

github "Alan881/AACarousel"

在终端中输入指令。

carthage update --platform iOS

用法

在安装AACarousel后,您必须在Storyboard中创建UIView并使用自定义类。

然后您还必须为具有AACarouselDelegate的UIViewController类创建一个IBOutlet。

以下是一个示例代码供您参考。

    var titleArray = [String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
     
        let pathArray = ["http://www.gettyimages.ca/gi-resources/images/Embed/new/embed2.jpg",
                        "https://ak.picdn.net/assets/cms/97e1dd3f8a3ecb81356fe754a1a113f31b6dbfd4-stock-photo-photo-of-a-common-kingfisher-alcedo-atthis-adult-male-perched-on-a-lichen-covered-branch-107647640.jpg",
                        "https://imgct2.aeplcdn.com/img/800x600/car-data/big/honda-amaze-image-12749.png",
                        "http://www.conversion-uplift.co.uk/wp-content/uploads/2016/09/Lamborghini-Huracan-Image-672x372.jpg",
                        "very-large-flamingo"]
        titleArray = ["picture 1","picture 2","picture 3","picture 4","picture 5"]
        carouselView.delegate = self
        carouselView.setCarouselData(paths: pathArray,  describedTitle: titleArray, isAutoScroll: true, timer: 5.0, defaultImage: "defaultImage")
        //optional methods
        carouselView.setCarouselOpaque(layer: false, describedTitle: false, pageIndicator: false)
        carouselView.setCarouselLayout(displayStyle: 0, pageIndicatorPositon: 5, pageIndicatorColor: nil, describedTitleColor: nil, layerColor: nil)
    }
    //require method
    func downloadImages(_ url: String, _ index: Int) {
        
        //here is download images area
         let imageView = UIImageView()
        imageView.kf.setImage(with: URL(string: url)!, placeholder: UIImage.init(named: "defaultImage"), options: [.transition(.fade(0))], progressBlock: nil, completionHandler: { (downloadImage, error, cacheType, url) in
            self.carouselView.images[index] = downloadImage!
        })
    }
    //optional method (interaction for touch image)
    func didSelectCarouselView(_ view: AACarousel ,_ index: Int) {
        
        let alert = UIAlertView.init(title:"Alert" , message: titleArray[index], delegate: self, cancelButtonTitle: "OK")
        alert.show()
        
        //startAutoScroll()
        //stopAutoScroll()
    }
    
    //optional method (show first image faster during downloading of all images)
    func callBackFirstDisplayView(_ imageView: UIImageView, _ url: [String], _ index: Int) {
        
        imageView.kf.setImage(with: URL(string: url[index]), placeholder: UIImage.init(named: "defaultImage"), options: [.transition(.fade(1))], progressBlock: nil, completionHandler: nil)
        
    }
    
    func startAutoScroll() {
       //optional method
       carouselView.startScrollImageView()
        
    }
    
    func stopAutoScroll() {
        //optional method
        carouselView.stopScrollImageView()
    }

许可

AACarousel在MIT许可下可用。有关更多信息,请参阅LICENSE文件。