Skip to content

More customizable Universal Split Controller for IOS device family.

License

Notifications You must be signed in to change notification settings

ytur/USController

Repository files navigation

USController
More customizable Universal Split Controller for IOS device family.

Platform License Version Carthage compatible SwiftPM compatible Reviewed by Hound

USController, aims to display two controllers simultaneously with much simpler and customizable ways than UISplitViewController.

Example

Download Example party-parrot project from repo to poke around.

iPhone-split-example iPad-split-example iPhone-overlap-example iPad-overlap-example

Requirements

• iOS 9.0+

• Xcode 11.0+

Installation

CocoaPods

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

pod 'USController'

Carthage

You can use Carthage to install USController by adding it to your Cartfile:

github "ytur/USController"

If you use Carthage to build your dependencies, make sure you have added USController.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.

Swift Package Manager

You can use The Swift Package Manager to install USController by adding the proper description to your Package.swift file:

// swift-tools-version:5.2
import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/ytur/USController.git", from: "1.1.0"),
    ]
)

Then run swift build whenever you get prepared.

Manually

To use this library in your project manually you may:

  1. for Projects, just drag Source folder to the project tree
  2. for Workspaces, include the whole USController.xcodeproj

Usage

Import USController to the controller which you want to use it as child controller.

import USController

USController can be configured easily by it's builder initializer methods. You must specify the parent controller with "parentController" parameter of Builder class. Master and Detail controllers can be set with builder methods.

let masterController = UIViewController()
let detailController = UIViewController()

let dataSource = USCDataSource.Builder(parentController: self)
                  .setMasterController(masterController, embedInNavController: true)
                  .setDetailController(detailController, embedInNavController: true)
                  .setAppearance(.visibleInit)
                  .setDirection(.trailing)
                  .showBlockerOnMaster(color: .black, opacity: 0.1, allowInteractions: true)
                  .swipeable()
                  .invokeAppearanceMethods()
                  .portraitAnimationProperties(duration: 0.35, forwardDampingRatio: 0.5)
                  .landscapeAnimationProperties(duration: 0.35, forwardDampingRatio: 0.5)
                  .portraitCustomWidth(100.0)
                  .landscapeCustomWidth(100.0)
                  .visibilityChangesListener(willStartBlock: { (targetVisibility) in
                    print("targetVisibility:\(targetVisibility)")
                  })
                  .build()                  

It returns current visibility state of detail controller.

dataSource.getCurrentVisibility()

It changes current visibility state of detail controller between "visible" and "invisible"

dataSource.detailToggle()

It removes the USController and its subviews permanently from parent controller and view.

dataSource.disposeTheController()

Forces the detail controller to hide if it's displayed and keep hidden despite toggle actions.

dataSource.forceToHide = true

Author

ytur, yasinturkoglu@yahoo.com

License

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