Advertisement
Guest User

Untitled

a guest
May 26th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. func drawProgress(toValue: Float) {
  2. let circlePath = UIBezierPath(arcCenter: CGPoint(x: self.contentView.frame.width / 2, y: self.contentView.frame.height / 2), radius: 30, startAngle: 0, endAngle: 6.28, clockwise: true)
  3. // create its cooresponding layer
  4. let circleLayer = CAShapeLayer()
  5. circleLayer.frame = self.contentView.bounds
  6. circleLayer.path = circlePath.CGPath
  7. circleLayer.strokeColor = UIColor.blackColor().CGColor
  8. circleLayer.fillColor = self.contentView.backgroundColor?.CGColor
  9. circleLayer.lineWidth = 1.0
  10. self.contentView.layer.addSublayer(circleLayer)
  11.  
  12. // create the animation
  13. let pathAnimation = CABasicAnimation(keyPath: "strokeEnd")
  14. pathAnimation.duration = 0.1
  15. pathAnimation.fromValue = NSNumber(float: 0.0)
  16. pathAnimation.toValue = NSNumber(float: toValue)
  17.  
  18. // apply the animation to path
  19. circleLayer.addAnimation(pathAnimation, forKey: "strokeEnd")
  20. }
  21.  
  22. func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
  23.  
  24. //...other code above to get the correct cell for index path, etc
  25. myCell.drawProgress(toValue:download.progress)
  26. //trackCell.progressView.progress = download.progress
  27. }
  28.  
  29. //myCell.progressView.progress = download.progress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement