Latest 1.1.2
Homepage https://github.com/ChaselAn/Octopus
License MIT
Platforms ios 9.0, requires ARC
Authors

Octopus

Requirements

  • Swift 4.2, iOS 9.0

Installation

  • With Cocoapods:

  • swift4.2:
pod 'Octopus', '~> 1.0.1'
# Then, run the following command:
$ pod install
  • swift5.0:
pod 'Octopus', '~> 1.1.2'
# Then, run the following command:
$ pod install

How to use

Octopus

    let octopusView = OctopusView()   
    octopusView.dataSource = self
        octopusView.delegate = self
//        if #available(iOS 11.0, *) {
//            octopusView.tableView.contentInsetAdjustmentBehavior = .never
//        }
        view.addSubview(octopusView)
        octopusView.translatesAutoresizingMaskIntoConstraints = false
        octopusView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
        octopusView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
        octopusView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
        octopusView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true

        octopusView.hangUpOffsetY = Int((navigationController?.navigationBar.bounds.height ?? 0) + UIApplication.shared.statusBarFrame.height)
//        octopusView.tableView.contentInset = UIEdgeInsets(top: 88, left: 0, bottom: 0, right: 0)
        view.layoutIfNeeded()
  • OctopusViewDataSource
public protocol OctopusViewDataSource: class {

    func numberOfPages(in octopusView: OctopusView) -> Int
    func octopusView(_ octopusView: OctopusView, pageViewControllerAt index: Int) -> OctopusPage

    func headerView(in octopusView: OctopusView) -> UIView?
    func headerViewHeight(in octopusView: OctopusView) -> Int

    func segmentView(in octopusView: OctopusView) -> UIView?
    func segmentViewHeight(in octopusView: OctopusView) -> Int
}
  • I suggest you implement the caching mechanism for page view by yourself.
private var vcs: [Int: OctopusDataViewController] = [:]
func octopusView(_ octopusView: OctopusView, pageViewControllerAt index: Int) -> OctopusPage {
        if let cacheVC = vcs[index] {
            return cacheVC
        }
        let vc = OctopusDataViewController()
        vc.index = index
        vcs[index] = vc
        return vc
    }

Latest podspec

{
    "name": "Octopus",
    "version": "1.1.2",
    "summary": "Octopus demo",
    "homepage": "https://github.com/ChaselAn/Octopus",
    "license": "MIT",
    "authors": {
        "ChaselAn": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/ChaselAn/Octopus.git",
        "tag": "1.1.2"
    },
    "source_files": "Octopus/*.swift",
    "requires_arc": true,
    "swift_versions": [
        "5.0",
        "4.2",
        "4.0"
    ]
}

Pin It on Pinterest

Share This