overlaying text on image using swift
<p>I am trying to overlay some text on an image using Swift and am looking at this code here: (src: <a href="https://stackoverflow.com/questions/28906914/how-do-i-add-text-to-an-image-in-ios-swift#">How do I add text to an image in iOS Swift</a>)</p>

<p>This places the text right in the center. I have been changing the values in</p>

<pre><code> var rect = CGRectMake(10,150, inImage.size.width,    
   inImage.size.height)
</code></pre>

<p>but I am unable to get the text to show in the lower left corner. Can someone help and show what I am missing here ? </p>

<p>I am adding the modified image using this line:</p>

<pre><code>modImage = self.textToImage("000", inImage: UIImage(named:"thisImage.png")!, atPoint: CGPointMake(10, 400))
</code></pre>

<p>Below is the function...</p>

<pre><code>func textToImage(drawText: NSString, inImage: UIImage, atPoint: CGPoint) -&gt; UIImage{

    // Setup the font specific variables
    var textColor = UIColor.whiteColor()
    var textFont = UIFont(name: "Helvetica Bold", size: 12)!

    // Setup the image context using the passed image
    let scale = UIScreen.mainScreen().scale
    UIGraphicsBeginImageContextWithOptions(inImage.size, false, scale)

    // Setup the font attributes that will be later used to dictate how the text should be drawn
    let textFontAttributes = [
        NSFontAttributeName: textFont,
        NSForegroundColorAttributeName: textColor,
    ]

    // Put the image into a rectangle as large as the original image
    inImage.drawInRect(CGRectMake(0, 0, inImage.size.width, inImage.size.height))

    // Create a point within the space that is as bit as the image
    var rect = CGRectMake(atPoint.x, atPoint.y, inImage.size.width, inImage.size.height)

    // Draw the text into an image
    drawText.drawInRect(rect, withAttributes: textFontAttributes)

    // Create a new image out of the images we have created
    var newImage = UIGraphicsGetImageFromCurrentImageContext()

    // End the context now that we have the image we need
    UIGraphicsEndImageContext()

    //Pass the image back up to the caller
    return newImage

}
</code></pre>