Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func drawProgress(toValue: Float) {
- 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)
- // create its cooresponding layer
- let circleLayer = CAShapeLayer()
- circleLayer.frame = self.contentView.bounds
- circleLayer.path = circlePath.CGPath
- circleLayer.strokeColor = UIColor.blackColor().CGColor
- circleLayer.fillColor = self.contentView.backgroundColor?.CGColor
- circleLayer.lineWidth = 1.0
- self.contentView.layer.addSublayer(circleLayer)
- // create the animation
- let pathAnimation = CABasicAnimation(keyPath: "strokeEnd")
- pathAnimation.duration = 0.1
- pathAnimation.fromValue = NSNumber(float: 0.0)
- pathAnimation.toValue = NSNumber(float: toValue)
- // apply the animation to path
- circleLayer.addAnimation(pathAnimation, forKey: "strokeEnd")
- }
- func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
- //...other code above to get the correct cell for index path, etc
- myCell.drawProgress(toValue:download.progress)
- //trackCell.progressView.progress = download.progress
- }
- //myCell.progressView.progress = download.progress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement