QiuDaniel / Aquaman

A pure-Swift library for nested display of horizontal and vertical scrolling views

Home Page:https://bawn.github.io/#blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aquaman

License MIT Pod version Platform info Support Swift 4.2

A pure-Swift library for nested display of horizontal and vertical scrolling views.

demo

Requirements

  • iOS 9.0+
  • Swift 4.2+
  • Xcode 10+

Installation

CocoaPods (recommended)

use_frameworks!

pod 'Aquaman'

Usage

中文文档

First make sure to import the framework:

import Aquaman

Basically, we just need to provide the list of child view controllers to show. Then call some necessary methods.

Let's see the steps to do this:

Create a AquamanPageViewController subclass

import Aquaman

class PageViewController: AquamanPageViewController {
  // ...
}

Provide the view controllers that will appear embedded into the AquamanPageViewController

override func numberOfViewControllers(in pageController: AquamanPageViewController) -> Int {
    return count
}
    
override func pageController(_ pageController: AquamanPageViewController, viewControllerAt index: Int) -> (UIViewController & AquamanChildViewController) {
    // ...
    return viewController
}
    

Every UIViewController that will appear within the AquamanPageViewController should conform to AquamanChildViewController by implementing func aquamanChildScrollView() -> UIScrollView

import Aquaman
class ChildViewController: UIViewController, AquamanChildViewController {

    @IBOutlet weak var tableView: UITableView!
    func aquamanChildScrollView() -> UIScrollView {
        return tableView
    }
    // ...
}

Provide the headerView and headerView height

override func headerViewFor(_ pageController: AquamanPageViewController) -> UIView {
    return HeaderView()
}

override func headerViewHeightFor(_ pageController: AquamanPageViewController) -> CGFloat {
    return headerViewHeight
}

Provide the menuView and menuView height

override func menuViewFor(_ pageController: AquamanPageViewController) -> UIView {
    return menuView
}

override func menuViewHeightFor(_ pageController: AquamanPageViewController) -> CGFloat {
    return menuViewHeight
}

Update menuView's layout when content scroll view did scroll and check state when did end scoll

override func pageController(_ pageController: AquamanPageViewController, contentScrollViewDidScroll scrollView: UIScrollView) {
    menuView.updateLayout(scrollView)
}

override func pageController(_ pageController: AquamanPageViewController,
                             contentScrollViewDidEndScroll scrollView: UIScrollView) {
    menuView.checkState()
}

Examples

Follow these 4 steps to run Example project:

  1. Clone Aquaman repository
  2. Run the pod install command
  3. Open Aquaman workspace
  4. Run the Aquaman-Demo project.

License

Aquaman is released under the MIT license. See LICENSE for details.

About

A pure-Swift library for nested display of horizontal and vertical scrolling views

https://bawn.github.io/#blog

License:MIT License


Languages

Language:Swift 96.6%Language:Objective-C 2.1%Language:Ruby 1.3%