title: How to prevent back button from dissapearing?
body: <p>I am creating a doodle page with an "X" as the close/dismiss button.
  I also have a "clear" button to remove the doodles that have been made.</p>
  
  <p>My issue is that when I press clear, even the X button disappears, how do I prevent this from happening?</p>
  
  <p>This is my current app.</p>
  
  <p><a href="https://i.stack.imgur.com/qfm88.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qfm88.png" alt="enter image description here"></a></p>
  
  <p>This is my Doodle class which allows me to draw on the view.</p>
  
  <pre><code>import UIKit
  
  class DoodleView: UIView {
  
      var lineColor:UIColor!
      var lineWidth:CGFloat!
      var path:UIBezierPath!
      var touchPoint:CGPoint!
      var startingPoint:CGPoint!
  
      override func layoutSubviews() {
          self.clipsToBounds = true
          self.isMultipleTouchEnabled = false
  
          lineColor = UIColor.white
          lineWidth = 10
      }
  
  
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          let touch = touches.first
          startingPoint = touch?.location(in: self)
      }
  
      override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          let touch = touches.first
          touchPoint = touch?.location(in: self)
  
          path = UIBezierPath()
          path.move(to: startingPoint)
          path.addLine(to: touchPoint)
          startingPoint = touchPoint
  
          drawShapeLayer()
      }
  
      func drawShapeLayer() {
          let shapeLayer = CAShapeLayer()
          shapeLayer.path = path.cgPath
          shapeLayer.strokeColor = lineColor.cgColor
          shapeLayer.lineWidth = lineWidth
          shapeLayer.fillColor = UIColor.clear.cgColor
          self.layer.addSublayer(shapeLayer)
          self.setNeedsDisplay()
      }
  
      func clearCanvas() {
          path.removeAllPoints()
          self.layer.sublayers = nil
          self.setNeedsDisplay()
      }
  }
  </code></pre>
  
  <p>This is the class controlling the view controller.</p>
  
  <pre><code>import UIKit
  
  class DoodlePageViewController: UIViewController {
  
  
      @IBOutlet weak var doodleView: DoodleView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
      }
  
  
      @IBAction func clearDoodle(_ sender: Any) {
          doodleView.clearCanvas()
      }
  
  
      @IBAction func CloseDoodlePage(_ sender: Any) {
          dismiss(animated: true, completion: nil)
      }
  }
  </code></pre>