There is likely an obvious answer but not sure why I'm missing it.
btn2.addTarget(self, action: #selector(ViewController.dismiss(_:)), forControlEvents: UIControlEvents.TouchUpInside)
func dismiss(sender: FlatButton){
self.dismissViewControllerAnimated(true, completion: nil)
}
I removed all unnecessary code for simplicity sake. The btn2 code is all within a separate func.
Found a solution.
Use
self.cardView.removeFromSuperview()
That can be accessed in a separate func.