title: How to change color of Triangle figure using drawRect on Swift
body: <p>I have made triangle view, called UpTriangleView. It is used in order to show vote. When they are tapped, I want to change their color. I wanna <code>UIColor.grayColor().setStroke()</code> from instance, however I have no idea how to do it. Please tell me how to do it, if you know. Thank you for your kindeness.</p>
  
  <pre><code>class UpTriangleView: UIView {
  
    override func drawRect(rect: CGRect) {
      self.backgroundColor = UIColor.clearColor()
      // Get Height and Width
      let layerHeight = self.layer.frame.height
      let layerWidth = self.layer.frame.width
  
      // Create Path
      let line = UIBezierPath()
  
      // Draw Points
      line.moveToPoint(CGPointMake(0, layerHeight))
      line.addLineToPoint(CGPointMake(layerWidth, layerHeight))
      line.addLineToPoint(CGPointMake(layerWidth/2, 0))
      line.addLineToPoint(CGPointMake(0, layerHeight))
      line.closePath()
  
      // Apply Color
      UIColor.grayColor().setStroke()
      UIColor.grayColor().setFill()
      line.lineWidth = 3.0
      line.fill()
      line.stroke()
  
      // Mask to Path
      let shapeLayer = CAShapeLayer()
      shapeLayer.path = line.CGPath
      self.layer.mask = shapeLayer
    }
  } 
  
  
  class QATableViewCell : UITableViewCell{   
    @IBOutlet weak var upTriangleView: UpTriangleView!
  }
  </code></pre>