Latest 1.1.6
Homepage https://github.com/SakuragiYoshimasa/FluctuateViewController
License MIT
Platforms ios 11.0
Authors

Platform
Swift
Cocoapods
Carthage compatible
License
pod

FluctuateViewController

Features

Assumed mainly used on iPad.
(Ex. acceptance application.)
Home view is covered by ‘CoverView’ to show the title or some purpose of the application.
To use effectively iPad’s high screen, the manipulation is done mainly by swipe up and down.

Installation and Setup

CocoaPods

pod 'FluctuateViewController'

Carthage

github "SakuragiYoshimasa/FluctuateViewController"

How to use

Make subclass of FluctuateViewController.
To use your custom menu view or cover view, inherit "MenuView" and "CoverView". If you want more detail, please see "CustomMenuView" and "CustomCoverView" in a Demo.

Basic setting

override func viewDidLoad() {
    super.viewDidLoad()
    //Setting propaties
    fluctuateView.setPropaties(propaties: FluctuateViewPropaties(animationDuration: 0.4, menuHeight: 300, offsetOnNocontent: 300, offsetOnFixedContent: 200, fullCoveredOffset: 60))
}

DataSource

// FluctuateViewDataSource
    override func contentsCount() -> Int { return 3 }

    override func fluctuateView(_ fluctuateView: FluctuateView, contentTitle index: Int) -> String {
        return "(index)"
    }

    override func fluctuateView(_ fluctuateView: FluctuateView, contentByIndex index: Int) -> UIViewController {

        switch index {
        case 0:
            return UIStoryboard(name: "FixedVCDemoVC", bundle: nil).instantiateInitialViewController()!
        case 1:
            return UIStoryboard(name: "FixedScrollDemoVC", bundle: nil).instantiateInitialViewController()!
        case 2:
            return UIStoryboard(name: "FullScrollDemoVC", bundle: nil).instantiateInitialViewController()!
        default:
            return UIViewController()
        }
    }

    override func fluctuateView(_ fluctuateView: FluctuateView, contentTypeByIndex index: Int) -> ContentViewType {
        return index < 2 ? .fixed : .full
    }

    override func coverView() -> CoverView {
        return CustomCoverView(frame: self.view.frame)
    }

    override func menuView() -> MenuView {
        return CustomMenuView(frame: self.view.frame)
    }

    override func noContentView() -> UIViewController {
        let vc = UIViewController()
        vc.view.backgroundColor = UIColor.darkGray
        return vc
    }

Delegate

// FluctuateViewDelegate
    override func onStateChage(_ state: FluctuateViewState){
        print("(state)")
    }

MenuView

Like this, your custom menu view need to inherit "MenuView" and override recreateMenuViewByContents and call select(contentIndex: Int) according to your situations.

  class CustomMenuView : MenuView {

    var buttons: [UIButton] = []

    override func recreateMenuViewByContents(dataSource: FluctuateViewDataSource){
        buttons.forEach({ $0.removeFromSuperview() })
        buttons = []

        for i in 1...dataSource.contentsCount() {
            let button = UIButton(frame: CGRect(x: i * 120 + 100,y: 100, width: 100, height: 60))
            button.backgroundColor = UIColor.black
            button.setTitleColor(UIColor.white, for: .normal)
            button.setTitle("(i)", for: .normal)
            button.tag = i
            button.addTarget(self, action: #selector(self.selectContent(_:)), for: .touchUpInside)
            buttons.append(button)
            addSubview(button)
        }
    }

    func selectContent(_ sender: UIButton) {
        select(contentIndex: sender.tag)
    }
}

CoverView

Only you need is inherit "CoverView".

License

MIT license. LICENSE

Latest podspec

{
    "name": "FluctuateViewController",
    "version": "1.1.6",
    "summary": "ViewController for a specific situation on iPad",
    "description": "ViewController for a specific situation on iPad.nThere have not been samples.",
    "homepage": "https://github.com/SakuragiYoshimasa/FluctuateViewController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "SakuragiYoshimasa": "[email protected]"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/SakuragiYoshimasa/FluctuateViewController.git",
        "tag": "v1.1.6"
    },
    "source_files": "FluctuateViewController/*",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This