Easier with scroll
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Merge branch 'master' of github.com:cillyfly/MXScroll Nov 14, 2018
MXScroll change to swif4.2 Nov 14, 2018
images add image Jul 23, 2018
.gitignore init Jul 19, 2018
.travis.yml edit ci Jul 23, 2018
LICENSE init Jul 19, 2018
MXScroll.podspec change version Aug 15, 2018
README.md Update README.md Aug 16, 2018
_Pods.xcodeproj init Jul 19, 2018




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.




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

WKWebView UIScrollView UIView
wkwebview UIScrollView UIView


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


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.


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

pod 'MXScroll'



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)


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)


cillyfly, cillyfly@163.com


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