UIImage to share

Quick fix for images I don't have.

After the user inputs their age and runs the calculation, they'll get an image back specific to their results. It turns out that we don't have images for all the ages, so I need to serve something.

The designer gave me an image with an empty space for the result number to show up. I used the result to set the text in a customTextView instance that I placed in the empty spot.

Then, when we're going to share it, we need to create a UIImage from this flattened imageView.

  private func shareMillionaireAge() {
    let text = Config.shareText
    if milAgeResult >= 50 {
      shareImage = resultImageView.image!
    } else {
      UIGraphicsBeginImageContextWithOptions(resultImageView.bounds.size, false, 0.0)
      let context: CGContextRef = UIGraphicsGetCurrentContext()
      shareImage = UIGraphicsGetImageFromCurrentImageContext()
    let activity = UIActivityViewController(activityItems: [shareImage, text], applicationActivities: nil)
    self.presentViewController(activity, animated: true, completion: nil)