Skip to content

Instantly share code, notes, and snippets.

@DanielAsher
Created April 24, 2016 21:23
Show Gist options
  • Select an option

  • Save DanielAsher/8112d5215074e554e959f2212fc03190 to your computer and use it in GitHub Desktop.

Select an option

Save DanielAsher/8112d5215074e554e959f2212fc03190 to your computer and use it in GitHub Desktop.
Demonstrates disappearing NavigationBar button in interactive playgrounds
import Foundation
import UIKit
import XCPlayground
struct UI {
let button = UIButton(frame: CGRect(x: 30, y: 30, width: 300, height: 30))
let vc = UIViewController()
init(title: String, buttonText: String? = nil) {
if let buttonText = buttonText {
vc.view.addSubview(button)
button.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
button.setTitle(buttonText, forState: UIControlState.Normal)
}
vc.title = title
vc.edgesForExtendedLayout = .None
vc.view.backgroundColor = UIColor.whiteColor()
}
}
let ui1 = UI(title: "Navigation Bar bug?", buttonText: "Tap to push next view controller")
let ui2 = UI(title: "Is the back button rendered?")
class NavigationController : UINavigationController {
}
let nav = NavigationController()
class PushViewControllerAction {
@objc func action() {
nav.pushViewController(ui2.vc, animated: true)
}
}
let pushViewControllerAction = PushViewControllerAction()
ui1.button.addTarget(pushViewControllerAction, action: #selector(PushViewControllerAction.action), forControlEvents: UIControlEvents.TouchUpInside)
nav.pushViewController(ui1.vc, animated: true)
XCPlaygroundPage.currentPage.liveView = nav
print("Finished set up")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment