iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

Suggestion - Can you please add a sample in Swift for Programmatic approach as well ? #26

Closed tariq235 closed 7 years ago

iDevelopper commented 7 years ago

Hi,

There are already two samples written in Swift! How can I help you?

tariq235 commented 7 years ago

I think both are using storyboard and segue. I am looking for programmatic approach instead of storyboard.

tariq235 commented 7 years ago

Programmatic approach was simple I have just implemented this great library!

iDevelopper commented 7 years ago
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        window = UIWindow(frame: UIScreen.main.bounds)

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

        let mainViewController = storyboard.instantiateViewController(withIdentifier: "MainViewController")
        let leftTableViewController = storyboard.instantiateViewController(withIdentifier: "LeftTableViewController")
        let rightViewController = storyboard.instantiateViewController(withIdentifier: "RightViewController")

        let revealViewController = PBRevealViewController(leftViewController: leftTableViewController, mainViewController: mainViewController, rightViewController: rightViewController)

        window?.rootViewController = revealViewController

        window?.makeKeyAndVisible()

        return true
    }