Skip to content

Instantly share code, notes, and snippets.

@baz8080
Created May 21, 2020 11:40
Show Gist options
  • Save baz8080/73509ac30935c91479d5e84078911766 to your computer and use it in GitHub Desktop.
Save baz8080/73509ac30935c91479d5e84078911766 to your computer and use it in GitHub Desktop.
Adding a close button when presenting a Unified SDK ViewController modally
private var backButton: UIBarButtonItem {
let barButtonItem = UIBarButtonItem(title: "Dismiss", style: .plain, target: self, action: #selector(dismissViewController))
if #available(iOS 13, *) {
barButtonItem.image = UIImage(systemName: "xmark")
}
return barButtonItem
}
@objc private func dismissViewController() {
navigationController?.dismiss(animated: true, completion: nil)
}
viewController.navigationItem.leftBarButtonItem = backButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment