Swift无限轮播
let images = ["http://c.hiphotos.baidu.com/image/pic/item/b58f8c5494eef01f50d40bbee5fe9925bd317d8c.jpg", "1", "2", "3", "4"]
let titles = ["Raindew","无限轮播", "QQ群:511860085", "欢迎加入", "帅的人已经Star"]
let cycleView = YLCycleView(frame: CGRect(x: 0, y: 100, width: self.view.bounds.width, height: 150), images: images, titles: titles)
view.addSubview(cycleView)
你可以在把本地图片名称直接放进数组里,也可以放一个URL 为了方便网络图片,我做了这样一个处理,但是同时我需要麻烦你在项目中引入Kingfisher 这个三方
cycleView.delegate = self;
func clickedCycleView(_ cycleView : YLCycleView, selectedIndex index: Int) {
print("点击了第\(index)页")
}
let cycleView = YLCycleView(frame: CGRect(x: 0, y: 100, width: self.view.bounds.width, height: 150), images: images)
// MARK: -- reload
func reload() {
cycleView.titles = []//可以为空。可以为nil-->此时隐藏标题
cycleView.images = ["1", "2", "3"]//不要为空,否则没图片了
//请务必刷新!
cycleView.reloadData()
}
self.automaticallyAdjustsScrollViewInsets = false
image
//类方法创建
let menuView = YLMenuView.ylMenuView()
menuView.frame = CGRect(x: 10, y: 320, width: self.view.bounds.width - 20, height: 250)
menuView.delegate = self
//你可以给一个URL也可以给一个本地图片
menuView.imageArray = ["http://tx.haiqq.com/uploads/allimg/150322/021422Lb-10.jpg",
"http://img.wzfzl.cn/uploads/allimg/150522/co150522214536-15.jpg",
"http://img.wzfzl.cn/uploads/allimg/150119/co150119220K2-18.jpg",
"http://uploads.xuexila.com/allimg/1608/704-160Q5100Z6.jpg",
"http://tx.haiqq.com/uploads/allimg/150326/1P4511163-9.jpg",
"http://tx.haiqq.com/uploads/allimg/150323/15135032M-1.jpg",
"http://img.wzfzl.cn/uploads/allimg/150522/co150522214536-15.jpg",
"http://img.wzfzl.cn/uploads/allimg/150119/co150119220K2-18.jpg",
"http://uploads.xuexila.com/allimg/1608/704-160Q5100Z6.jpg",
"http://tx.haiqq.com/uploads/allimg/150326/1P4511163-9.jpg",
"http://tx.haiqq.com/uploads/allimg/150323/15135032M-1.jpg",
"http://tx.haiqq.com/uploads/allimg/150323/15135032M-1.jpg",
"1"
]
menuView.titleArray = ["http", "2345", "345", "uploads", "2345", "allimg", "34545", "uploads", "345", "http", "uploads", "uploads", "uploads"]
// menuView.itemsOfPage = 6
// menuView.imageViewSize = CGSize(width: 60, height: 60)
// menuView.pageControl.pageIndicatorTintColor = .white
// menuView.pageControl.currentPageIndicatorTintColor = .darkGray
view.addSubview(menuView)
MenuView.gif
let singlerView = YLSinglerowView(frame: CGRect(x: 50, y: 350, width: 200, height: 30), scrollStyle: .up, roundTime: 5, contentSource: ["这是一条重大新闻","吃货节到了钱包准备好了吗","独家福利来就送!"], tagSource: ["新闻", "吃货节", "福利"])
singlerView.delegate = self
//更多公开属性自行查找
// singlerView.backColor = .darkGray
// singlerView.contentTextColor = .purple
// singlerView.tagBackgroundColors = [.white,.yellow,.cyan]
// singlerView.tagTextColors = [.red,.blue,.black]
view.addSubview(singlerView)
self.automaticallyAdjustsScrollViewInsets = false
//MARK: -- YLSinglerViewDelegate
func singlerView(_ singlerowView: YLSinglerowView, selectedIndex index: Int) {
print("点击了第\(index)个数据")
}
image
image
image