mxs

MXScroll

Easier with scroll

Showing:

Popularity

Downloads/wk

0

GitHub Stars

162

Maintenance

Last Commit

9mos ago

Contributors

2

Package

Dependencies

3

License

MIT

Categories

Readme

banner

MXScroll

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.

WKWebViewUIScrollViewUIView
wkwebviewUIScrollViewUIView

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.

To work with Swift 5.0 use MXScroll v.0.1.3

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, cillyfly@163.com

License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100