CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

LCALoopBanner 1.0.4

LCALoopBanner 1.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by lichangan.



  • By
  • changan931

LCALoopBanner是用一个ScrollView和三个UIImageView实现的一个无限轮播器。

image

Requirements

Swift 3.0 iOS8.0 Xcode8.0以上

Installation

LCALoopBanner is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'LCALoopBanner'
 class BannerModel:LCALoopBannerProtocol {

    /// 广告图片URL
    internal var imageURL: URL

    internal var clickBlock: (() -> ())
    
    init(url:URL,clickBlock:@escaping (()->())) {
        self.imageURL = url
        self.clickBlock = clickBlock
    }
}

class ViewController: UIViewController {

    var images:[String] = ["http://fdfs.xmcdn.com/group19/M04/AD/7E/wKgJJle6V2ahiSTZAAEU72DrYKE225.jpg","http://fdfs.xmcdn.com/group10/M00/6A/6D/wKgDaVc5q6WgTQflAAP0rP70Xw4865.jpg","http://fdfs.xmcdn.com/group27/M06/6C/83/wKgJW1kAQlahJ3UgAAE3bPtCzp8506.jpg","http://fdfs.xmcdn.com/group27/M08/26/1C/wKgJR1jLVjODCfl2AAGcRAN-aYg653.jpg","http://fdfs.xmcdn.com/group23/M04/92/22/wKgJNFimejfByOeXAADEj9xi3Ic318.jpg"]
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        var models = [BannerModel]()
        for urlString in images {
            if let url = URL(string: urlString) {
                 let model = BannerModel(url: url, clickBlock: { 
                    print("被点击了")
                    print(url.absoluteString)
                 })
                models.append(model)
            }
        }
       
        let loopBanner = LCALoopBanner.loopBanner { (imageView, url) in
           imageView.kf.setImage(with: url)
        }
        loopBanner.bannerModels = models
        loopBanner.delegate = self
        loopBanner.frame = CGRect(x: 0, y:20, width: view.bounds.size.width, height: 200)
        view.addSubview(loopBanner)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
}

Author

[email protected], [email protected]

License

LCALoopBanner is available under the MIT license. See the LICENSE file for more info.