Latest 0.1.0
Homepage https://github.com/tamanyan/UnlimitedScrollView
License MIT
Platforms ios 8.0, requires ARC
Authors

UnlimitedScrollView provides an endlessly UIScrollView

Demo

Usage

initialize a UnlimitedScrollView new instance.

let scrollView = UnlimitedScrollView(frame: UIScreen.mainScreen().applicationFrame)
scrollView.unlimitedScrollViewDataSource = self
scrollView.unlimitedScrollViewDelegate = self
scrollView.firstVisiblePageIndex = 0
self.view.addSubview(self.scrollView)
scrollView.reloadData()

Finally, implement the UnlimitedScrollViewDataSource and UnlimitedScrollViewDelegate protocols methods.

extension ViewController: UnlimitedScrollViewDataSource {
    func numberOfPagesInUnlimitedScrollView(unlimitedScrollView: UnlimitedScrollView) -> Int {
        return 10
    }

    func numberOfVisiblePagesInUnlimitedScrollView(unlimitedScrollView: UnlimitedScrollView) -> Int {
        return 3
    }

    func unlimitedScrollView(unlimitedScrollView: UnlimitedScrollView, pageForItemAtIndex index: Int) -> UnlimitedScrollViewPage {
        let page = unlimitedScrollView.dequeueReusablePage()
        let textLabel = UILabel(frame: CGRect(origin: CGPoint.zero, size: unlimitedScrollView.pageSize))
        textLabel.text = "(index)"
        textLabel.textColor = UIColor.blackColor()
        textLabel.font = UIFont.boldSystemFontOfSize(30)
        textLabel.textAlignment = .Center
        page?.customView = textView
        return page!
    }
}
extension ViewController: UnlimitedScrollViewDelegate {
    func unlimitedScrollViewArrivePage(unlimitedScrollView: UnlimitedScrollView, page: UnlimitedScrollViewPage) {
        print("arrive page (page.index)")
    }

    func unlimitedScrollViewLeavePage(unlimitedScrollView: UnlimitedScrollView, page: UnlimitedScrollViewPage) {
        print("leave page (page.index)")
    }

    func unlimitedScrollViewRemovePage(unlimitedScrollView: UnlimitedScrollView, page: UnlimitedScrollViewPage) {
        print("remove page (page.index)")
    }

    func unlimitedScrollViewAddPage(unlimitedScrollView: UnlimitedScrollView, page: UnlimitedScrollViewPage) {
        print("add page (page.index)")
    }
}

Latest podspec

{
    "name": "UnlimitedScrollView",
    "version": "0.1.0",
    "summary": "UnlimitedScrollView provides an endlessly UIScrollView",
    "homepage": "https://github.com/tamanyan/UnlimitedScrollView",
    "screenshots": "https://raw.githubusercontent.com/tamanyan/UnlimitedScrollView/master/images/demo.gif",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Taketo Yoshida": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tamanyan/UnlimitedScrollView.git",
        "tag": "0.1.0"
    },
    "source_files": "UnlimitedScrollView/UnlimitedScrollView/*.{h,swift}",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This