swift 中的 3D 立方体过渡视图

3D cube Transition view in swift

我有 3 个视图 (UIViewController)。我想像这样制作 3d 立方体 Link。但是这个 link 项目被 objective C 使用,但我需要 swift 语言。请问我可以获得这个项目的资源吗?我正在尝试使用 Bridging-Header.h 但无法正常工作!!

我的代码如下:

import UIKit

class SecondViewController: CubeController, CubeControllerDataSource, CubeControllerDelegate {


override func viewDidLoad() {
    super.viewDidLoad()



    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


func numberOfViewControllersInCubeController(cubeController: CubeController!) -> Int {
    return 3
}

func cubeController(cubeController: CubeController!, viewControllerAtIndex index: Int) -> UIViewController! {
    switch(index % 3){

    case 0:
        return AViewController(nibName: "MyViewController", bundle: nil)
    case 1:
        return BViewController()
    case 2:
        return CViewController()

    default:
        return nil

    }
}

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

}

https://maniacdev.com/2013/11/library-allowing-you-to-easily-set-up-view-navigation-with-3d-cube-transitions

您必须为此使用桥接头 类 :

带有 swift 集成的示例代码:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CubeControllerDataSource {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        self.window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
        let cubeVC : CubeController = CubeController()
        cubeVC.dataSource = self
        cubeVC.wrapEnabled = true
        self.window?.rootViewController = cubeVC
        self.window?.makeKeyAndVisible()

        // Override point for customization after application launch.
        return true
    }

    func numberOfViewControllersInCubeController(cubeController: CubeController!) -> Int {
        return 3
    }

    func cubeController(cubeController: CubeController!, viewControllerAtIndex index: Int) -> UIViewController! {

        let storyboard = UIStoryboard(name: "Main", bundle: nil)

        switch (index % 3){
            case 0:
                return storyboard.instantiateViewControllerWithIdentifier("VC1")
            case 1:
                return storyboard.instantiateViewControllerWithIdentifier("VC2")
            case 2:
                return storyboard.instantiateViewControllerWithIdentifier("VC3")
            default:
                return nil
        }
    }
}