ZCycleView 1.0.4

ZCycleView 1.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2021
SPMSupports SPM

Maintained by mengqingzheng.



  • By
  • MQZHot

ZCycleView

A picture/text infinite-scroll library with UICollectionView, It can be very easy to help you make the banner you want

使用UICollectionView实现常见图片/文字无限轮播,支持自定义pageControl,自定义文字样式,以及轮播样式

使用方法

let cycleView = ZCycleView(frame: frame)
cycleView.placeholderImage = UIImage(named: "placeholder")
cycleView.setUrlsGroup(["http://...", "http://...", "http://..."])
cycleView.delegate = self
view.addSubview(cycleView)

要显示网络图片,需要实现下面的代理方法。

你可以选择自己喜欢的图片加载库进行显示图片,例如Kingfisher或者SDWebImage

func cycleViewConfigureDefaultCellImageUrl(_ cycleView: ZCycleView, imageView: UIImageView, imageUrl: String?, index: Int) {
    imageView.sd_setImage(with: URL(string: imageUrl!), placeholderImage: cycleView.placeholderImage)
}

显示本地图片,需要实现下面的代理方法

func cycleViewConfigureDefaultCellImage(_ cycleView: ZCycleView, imageView: UIImageView, image: UIImage?, index: Int) {
    imageView.image = image
}

修改pageControl或者label的样式,你可以使用下面的代理方法

func cycleViewConfigureDefaultCellText(_ cycleView: ZCycleView, titleLabel: UILabel, index: Int) {
    titleLabel.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6)
    titleLabel.textColor = .white
    titleLabel.font = UIFont.systemFont(ofSize: 13)
}

func cycleViewConfigurePageControl(_ cycleView: ZCycleView, pageControl: ZPageControl) {
    pageControl.pageIndicatorTintColor = UIColor.green
    pageControl.currentPageIndicatorTintColor = UIColor.red
}

自定义cell样式

@objc optional func cycleViewCustomCellIdentifier() -> String
@objc optional func cycleViewCustomCellClass() -> AnyClass
@objc optional func cycleViewCustomCellClassNib() -> UINib
@objc optional func cycleViewCustomCellSetup(_ cycleView: ZCycleView, cell: UICollectionViewCell, for index: Int)

联系方式

LICENSE

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