MKCubeController is used to create a rotating 3D cube navigation in Swift 2.1. (translated from @nicklockwood CubeController) here the link https://github.com/nicklockwood/CubeController Pretty much the same logic.
- iOS 9.0+
- Xcode 9.2+
Pretty easy !
let controller = MKCubeViewController()
controller.dataSource = self
controller.wrapEnabled = trueAnd implement MKCubeViewControllerDataSource
func numberOfViewControllersInCubeController(cubeController: MKCubeViewController) -> Int {
return 3
}
func cubeController(cubeController: MKCubeViewController, viewControllerAtIndex index: Int) -> UIViewController {
switch index % 3 {
case 0:
return ViewController(nibName: "RedViewController", bundle: nil)
case 1:
return ViewController(nibName: "GreenViewController", bundle: nil)
case 2:
return ViewController(nibName: "BlueViewController", bundle: nil)
default:
break
}
return ViewController()
}Embedded frameworks require a minimum deployment target of iOS 9.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapodsCocoaPods 1.3.1+ is required to build MKCubeController 1.1+.
To integrate MKCubeController into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'MKCubeController', '~> 1.1'Then, run the following command:
$ pod install- Open up Terminal,
cdinto your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
$ git init- Add MKCubeController as a git submodule by running the following command:
$ git submodule add https://github.com/kmalkic/MKCubeController.git-
Open the new
MKCubeControllerfolder, and drag theMKCubeController.xcodeprojinto the Project Navigator of your application's Xcode project.It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
-
Select the
MKCubeController.xcodeprojin the Project Navigator and verify the deployment target matches that of your application target. -
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
-
In the tab bar at the top of that window, open the "General" panel.
-
Click on the
+button under the "Embedded Binaries" section. -
You will see two different
MKCubeController.xcodeprojfolders each with two different versions of theMKCubeController.frameworknested inside aProductsfolder.It does not matter which
Productsfolder you choose from, but it does matter whether you choose the top or bottomMKCubeController.framework. -
And that's it!
The
MKCubeController.frameworkis automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
Kevin Malkic
MKCubeController is released under the MIT license. See LICENSE for details.