Skip to content

Instantly share code, notes, and snippets.

@mendesbarreto
Last active September 12, 2019 18:00
Show Gist options
  • Save mendesbarreto/b8526c48dda9ab42771e8e4b0f211c46 to your computer and use it in GitHub Desktop.
Save mendesbarreto/b8526c48dda9ab42771e8e4b0f211c46 to your computer and use it in GitHub Desktop.
Example of how to create a view controller with nib
//
// HomeViewControllerTests.swift
// DitMoi
//
// Created by Douglas Barreto on 10/01/18.
// Copyright © 2018 Douglas Mendes. All rights reserved.
//
import UIKit
final class HomeViewController: UIViewController {
@IBOutlet var label: UILabel!
var hello: String!
private init() {
super.init(nibName: String.init(describing: type(of: self)), bundle: nil)
}
convenience init(hello: String){
self.init()
self.hello = hello
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
label.text = hello
UIView.animate(withDuration: 5, animations: {
}) { _ in
self.navigationController?.pushViewController(HomeViewController(hello: "Test with xib"), animated: true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment