title: How do I draw a line in iOS swift in the viewDidLoad() function?
body: <p>I keep getting the following error when trying to draw a green line in my viewDidLoad(). It is important that I do it here because it's in between new labels when they are being placed down. The error is:</p>
  
  <pre><code>&lt;Error&gt;: CGContextSetLineWidth: invalid context 0x0. If you want to see 
   the backtrace, 
   please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
  </code></pre>
  
  <p>The code for drawing the line(s) is below:</p>
  
  <pre><code>    let context = UIGraphicsGetCurrentContext()
                          CGContextSetLineWidth(context, 3.0)
                          CGContextSetStrokeColorWithColor(context,self.hexStringToUIColor("#008500").CGColor)
                          CGContextMoveToPoint(context, 0,CGFloat(top+40))
                          CGContextAddLineToPoint(context, CGFloat(screenWidth*2), CGFloat(top+40))
                          CGContextStrokePath(context)
  </code></pre>