title: Is it possible to add an Image to a CGFloat
body: <p>I am trying to create a progress bar that goes from 0%-100%. When the progress reaches 100%, I would like it to fade from the percentage to an image such as a check mark. I am setting this progress bar up as a CAShapeLayer and inside of it, I would like the the image to appear after it reaches 100. I see this animation done throughout various apps and I'm wondering if it is possible to do in Xcode. I have tried to do this by converting an image to a CAShapeLayer but it fails with a compiler error:</p>
  
  <blockquote>
    <p>Cannot convert value of type 'UIImage?' to expected argument type 'String'</p>
  </blockquote>
  
  <p>I have used the code below, but it only shows the percentage of loading.
  is it possible to be done?  </p>
  
  <pre><code>  private func beginDownloadingFile() {
      print("Attempting to download file")
  
      shapeLayer.strokeEnd = 0
  
      let configuration = URLSessionConfiguration.default
      let operationQueue = OperationQueue()
      let urlSession = URLSession(configuration: configuration, delegate: self, delegateQueue: operationQueue)
  
      guard let url = URL(string: urlString) else { return }
      let downloadTask = urlSession.downloadTask(with: url)
      downloadTask.resume()
  }
  
  func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
      let percentage = CGFloat(totalBytesWritten) / CGFloat(totalBytesExpectedToWrite)
  
      DispatchQueue.main.async {
          self.percentageLabel.text = "\(Int(percentage * 100))%"
          self.shapeLayer.strokeEnd = percentage
          AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
      }
  
      print(percentage)
  }
  
  func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
      print("Finished downloading file")
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/d7uQ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d7uQ7.png" alt="percentage label that I want to change when reached 100%"></a></p>
  
  <p>Thank you for explaining whether or not this can be accomplished in advance. </p>