Code Monkey home page Code Monkey logo

scrollmenusviewcontroller's Introduction

ScrollMenusViewController

swift4 滑动菜单,每一个被滑动的页面都是一个VC。

如果想用每一个滑动页面是View的话,可以使用另一个sdk——ScrollMenusView,地址是:

https://github.com/weiman152/ScrollMenusView

支持cocoa pods

platform :ios, '9.0' inhibit_all_warnings!

target '你的项目名字' do use_frameworks!

pod ScrollMenusViewController

end

效果图:

Alt text Alt Text

Alt Text Alt Text

Alt Text Alt Text

Alt Text Alt Text

Alt Text Alt Text

Alt Text Alt Text Alt Text



使用示例:

// // SplitScreenTextViewController.swift

// ScrollMenusViewControllerDemo

// // Created by iOS on 2018/12/11.

// Copyright © 2018 weiman. All rights reserved.

//

import UIKit

class SplitScreenTextViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    setup()
    
}

private func setup() {
    let scrollMenuVC = ScrollMenuViewController.instance(
        type: .splitTheScreen,
        titleType: .text(titles: ["女装", "男装", "衣帽", "鞋袜"]),
        superVC: self,
        frame: CGRect(x: 0,
                      y: 84,
                      width: view.bounds.size.width,
                      height: view.bounds.size.height - 84)
    )
    view.addSubview(scrollMenuVC.view)
    scrollMenuVC.dataSource = self
}

static func instance() -> SplitScreenTextViewController {
    let storyBoard = UIStoryboard(name: "WM", bundle: nil)
    let vc = storyBoard.instantiateViewController(withIdentifier: "SplitScreenTextViewController") as! SplitScreenTextViewController
    return vc
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    dismiss(animated: true)
}

}

extension SplitScreenTextViewController: ScrollMenuViewControllerDataSource {

func menu(viewController: UIViewController, index: Int) {
    
    var vc = UIViewController()
    switch index % 3 {
    case 0:
        vc = ChildListViewController.instance(index: index)
    case 1:
        vc = ChildImageViewController.instance(index: index)
    case 2:
        vc = ChildTextViewController.instance(index: index)
    default: break
    }
    
    viewController.addChildViewController(vc)
    viewController.view.addSubview(vc.view)
    vc.view.frame = viewController.view.bounds
}

}

scrollmenusviewcontroller's People

Contributors

weiman152 avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.