More customizable Universal Split Controller for IOS device family.
USController, aims to display two controllers simultaneously with much simpler and customizable ways than UISplitViewController.
• iOS 9.0+
• Xcode 11.0+
USController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'USController'
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.
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.
To use this library in your project manually you may:
- for Projects, just drag Source folder to the project tree
- for Workspaces, include the whole USController.xcodeproj
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
ytur, yasinturkoglu@yahoo.com
USController is available under the MIT license. See the LICENSE file for more info.