Fork me on GitHub

无限Banner轮播图

GJImageCarouselView

自己写的Banner轮播图,自动循环,无限轮播。可以设置时间间隔、占位图。可以使用本地图片,也可以加载URL。

Demo工程中用到了喵神的kingfisher,一个非常好用的图片下载、缓存的框架,灵感取自于SDWebImage

初始化

1
2
3
4
5
6
7
8
9
let imageCarouselView = GJImageCarouselView(
frame: CGRect.init(x: 0, y: 0, width: ScreenWidth, height: ScreenWidth/375*180),
imageTapBlock: { (index) in
self.imageTapBlock!(index)
})
imageCarouselView.imageUrlList = ["https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-1.jpg",
"https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-2.jpg",
"https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-3.jpg"]
imageCarouselView.autoScrollInterval = 3

如果你使用AutoLayout进行页面布局的话,需要在布局完成后,调用layoutIfNeeded()

写在最后

源码地址:https://github.com/Geselle-Joy/GJImageCarouselView

-------------本文结束感谢您的阅读-------------

本文作者:乔羽 / FightingJoey

发布时间:2017年05月28日 - 10:11

最后更新:2018年09月27日 - 10:10

原始链接:https://fightingjoey.github.io/2017/05/28/开发/无限Banner轮播图/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

坚持原创技术分享,您的支持将鼓励我继续创作!