TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Aug 2016 |
SPMSupports SPM | ✗ |
Maintained by George Kye.
A customizable, easy to use infinite scroll view similar to the App Store banner.
GKAutoScrollingView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "GKAutoScrollingView"
Check out the demo.
1: Add AutoScrollingView
to your UIViewController
.
2: Set dataSource
and delegate
(optional)
class ViewController: UIViewController, AutoScrollingViewDataSource, AutoScrollingViewDelegate {
var autoScrollView: AutoScrollingView!
override func viewDidLoad() {
super.viewDidLoad()
autoScrollView = AutoScrollingView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 300))
autoScrollView.dataSource = self
autoScrollView.delegate = self
self.view.addSubview(autoScrollView)
}
}
3: Conform to AutoScrollingView
dataSource
extension MyViewController: AutoScrollingViewDataSource{
func createImageViews()->[UIImageView]{
var array: [UIImageView] = []
for index in 0...3 {
let img = UIImageView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 300))
img.image = UIImage(named: "\(index)")
array.append(img)
}
return array
}
func setAutoScrollingViewDataSource(autoScrollingView: AutoScrollingView) -> [UIView] {
return createImageViews()
}
}
4: Conform to AutoScrollingView
delegate
(all optional)
extension MyViewController: AutoScrollingViewDelegate{
func autoScrollingView(autoScrollingView: AutoScrollingView, didSelectItem index: Int) {
print("did select")
}
func autoScrollingView(autoScrollingView: AutoScrollingView, didChangeStatus status: ScrollingState) {
print(status.rawValue)
}
func autoScrollingView(autoScrollingView: AutoScrollingView, didAutoScroll index: Int) {
print("auto scrolling at index ", index)
}
}
Return an array of UIView's
to be used within the ScrollView
func setAutoScrollingViewDataSource(autoScrollingView: AutoScrollingView)->[UIView]
Returns the index of the selected view
optional func autoScrollingView(autoScrollingView: AutoScrollingView, didSelectItem index: Int)
Returns the index of currentItem
before view is scrolled
optional func autoScrollingView(autoScrollingView: AutoScrollingView, didAutoScroll index: Int)
Returns an AutoScrollingView
the status of the scroll automation. (Unpaused
or Paused
optional func autoScrollingView(autoScrollingView: AutoScrollingView, didChangeStatus status: ScrollingState)
Stops the automation of the ScrollView
pauseScrolling()
Starts the automation of scrolling (if scrolling is paused)
startScrolling()
Set the interval between autoScrolling
. Default is 2.0
seconds.
public var timerInterval: Double!
GKAutoScrollingView is available under the MIT license. See the LICENSE file for more info.