Latest 0.1.2
Homepage https://github.com/cillyfly/MXScroll
License MIT
Platforms ios 10.0
Dependencies RxSwift, RxCocoa, EasyPeasy
Authors

banner

Version
License
Platform

MXScroll is a framework that lets you create mix scroll view easier. you can just provide the datasource and do not need to consider the page composition. the datasource can be provided by storyboard or programmatically.

Structure

structure

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

WKWebView UIScrollView UIView
wkwebview UIScrollView UIView

Requirements

  • Xcode 9+
  • Swift 4.0+
  • iOS 10.0+

Installation

Swift compatibility

To work with Swift 4.0 use MXScroll v.0.1.0.

To work with Swift 4.1 use MXScroll v.0.1.2.

Cocoapods

MXScroll is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'MXScroll'

Usage

Simple

1. First you should
import MXScroll
2. Prepare Header
let header = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "HeaderViewController")

if WKWebView , UIWebView or UIScrollView is in HeaderVC, you should implement MXViewControllerViewSource.

extension HeaderViewController:MXViewControllerViewSource{
      func headerViewForContentOb() -> UIView? {
          return webView
      }
}
3. Prepare Content
let child1 = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ChildViewController")

if UITableView or UIScrollView is in ContentVC, you should implement MXViewControllerViewSource

extension ChildViewController:MXViewControllerViewSource{
       func viewForMixToObserveContentOffsetChange() -> UIView {
           return self.tableView
       }
}
4. Prepare Segment

You can use the MSSegmentControl provide by MXScroll

  let segment = MSSegmentControl(sectionTitles: ["1", "2"])
5. Mix
let header = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "HeaderViewController")

let child1 = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ChildViewController")

let child2 = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "SecondViewController")

let segment = MSSegmentControl(sectionTitles: ["1", "2"])

let mx = MXViewController<MSSegmentControl>.init(headerViewController: header, segmentControllers: [child1, child2], segmentView: segment)
navigationController?.pushViewController(mx, animated: true)

Segment

If you want to use the custom Segment,Just implementMXSegmentProtocol

extension MSSegmentControl: MXSegmentProtocol {
    // segment change to tell vc
    public var change: ((Int) -> Void) {
        get {
            return self._didIndexChange
        }
        set {
            self._didIndexChange = newValue
        }
    }

    // vc change callback method
    public func setSelected(index: Int, animator: Bool) {
        self.setSelected(forIndex: index, animated: animator, shouldNotify: true)
    }
}

Author

cillyfly, [email protected]

License

MXScroll is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MXScroll",
    "version": "0.1.2",
    "summary": "Mix Scroll easy",
    "description": "MXScroll is a view foundation for some mix scrollview with segmentview. it will make the work easy",
    "homepage": "https://github.com/cillyfly/MXScroll",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "cillyfly": "[email protected]"
    },
    "source": {
        "git": "https://github.com/cillyfly/MXScroll.git",
        "tag": "0.1.2"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_version": "4.0",
    "source_files": "MXScroll/Classes/**/*",
    "dependencies": {
        "RxSwift": [],
        "RxCocoa": [],
        "EasyPeasy": []
    }
}

Pin It on Pinterest

Share This