WWCircularCollectionView
一個可以無限滾動的滾輪
使用範例
import UIKit
import WWCircularCollectionView
class ViewController: UIViewController {
@IBOutlet weak var nowLabel: UILabel!
@IBOutlet weak var lastLabel: UILabel!
@IBOutlet weak var collectionView: WWCircularCollectionView!
let isInfinity = true
override func viewDidLoad() {
super.viewDidLoad()
delegateSetting()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
extension ViewController {
func delegateSetting() {
guard let layout = collectionView.collectionViewLayout as? WWCircularCollectionViewLayout else { return }
layout.wwDelegate = self
collectionView.wwDelegate = self
}
}
extension ViewController: WWCircularCollectionViewDelegate {
func isInfinity(_ wwCircularCollectionView: WWCircularCollectionView) -> Bool {
return isInfinity
}
func imagesDiectory(_ wwCircularCollectionView: WWCircularCollectionView) -> [String] {
return Bundle.main.paths(forResourcesOfType: "png", inDirectory: "Images")
}
}
extension ViewController: WWCircularCollectionViewLayoutDelegate {
func wwCircularCollectionViewLayout(_ wwCircularCollectionViewLayout: WWCircularCollectionViewLayout, selectedIndex index: Int) {
nowLabel.text = index.description
}
func wwCircularCollectionViewLayout(_ wwCircularCollectionViewLayout: WWCircularCollectionViewLayout, lastSelectedIndex index: Int) {
lastLabel.text = index.description
}
}