title: How to change fillColor of UIGraphicsGetCurrentContext?
body: <p>I've written this custom UIView class to draw custom shape</p>
  
  <pre><code>class ShapeView: UIView {
  
  var color: UIColor?
  
  init(frame: CGRect, color: UIColor) {
      super.init(frame: frame)
      self.color = color
  }
  
  required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
  }
  
  override func draw(_ rect: CGRect) {
      super.draw(rect)
      drawShape(rect: rect, color: self.color!)
  }
  
  func drawShape(rect: CGRect,color: UIColor) {
      guard let ctx = UIGraphicsGetCurrentContext() else { return }
      ctx.setFillColor(UIColor.clear.cgColor)
  
      ctx.beginPath()
      ctx.move(to: CGPoint(x: rect.width / 2, y: 0))
      ctx.addLine(to: CGPoint(x: rect.width, y: rect.height / 2))
      ctx.addLine(to: CGPoint(x: rect.width / 2 , y: rect.height))
      ctx.addLine(to: CGPoint(x: 0, y: rect.height / 2))
  
  
      ctx.closePath()
      ctx.setFillColor(color.cgColor)
      ctx.fillPath()
      ctx.strokePath()
  }
  
  override func point(inside point: CGPoint, with event: UIEvent?) -&gt; Bool {
      let path = UIBezierPath(ovalIn: self.frame)
      return path.contains(point)
  }
  </code></pre>
  
  <p>and when the user pressed somewhere inside the shape I need to change the fillColor of this shape to let's say black with this code // while debugging the color didn't change it's look like I did something wrong.</p>
  
  <p>in some UIViewController class I wrote this method</p>
  
  <pre><code>  class SomeClass: UIViewController {
     var shape1: ShapeView?
     var frame: CGRect?
  
    override func viewDidLoad() {
     let x = view.frame.midX
      let y = view.frame.midY
  
      self.frame = CGRect(x: x, y: y, width: 100, height: 100)
     super.viewDidLoad()
     self.shape1 = ShapeView(frame: frame!, color: .red)
      shape1?.backgroundColor = .clear
      view.addSubview(shape1!)
  }
  override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      let location = touches.first!.location(in: self.view)
      if (shape1?.point(inside: location, with: event))! {
          print("inside shape1")
          shape1?.drawShape(rect: frame!, color: .black)
      } else {
          print("outside shape1")
          shape1?.drawShape(rect: frame!, color: .red)
      }
    }
  </code></pre>
  
  <p>any ideas !</p>