swift轮播图

swift轮播图_第1张图片

效果如上图所示


调用方法:

let scrollView = LXJSycleScrollView(frame: CGRect(x: 0, y: 64, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width / 2))

//当前选中颜色

scrollView.currentPageColor = UIColor.gray

scrollView.pageColor = UIColor.white

//默认占位图

scrollView.placeHolderImage = UIImage (named: "place_image")

scrollView.timeSeconds = 2

scrollView.delegate = self

view.addSubview(scrollView)

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: {

//存放图片的数组,本地和网络的都可以

scrollView.imageArray = ["001.jpg","002.jpg","003.jpg","http://tupian.enterdesk.com/2015/gha/09/1502/01.jpg","http://img.ithome.com/newsuploadfiles/2016/3/20160317_080446_325.jpg"]

})


//点击的回调方法,需要遵循协议

func didClickBannerIndex(index: Int) {

print("点击了第\(index)个")

}


需要使用Kingfisher这个三方框架

你可能感兴趣的:(swift轮播图)