1

I want to display my upload progress of a file in the table view cell. I am using Progress View programatically for the same. However, the progress view overlaps the file name and its related data. How can I make the progress view appear behind the text?

Following is the code used:

let animationProgress = UIProgressView(progressViewStyle: .bar)
var prog: Float = 0.0

   animationProgress.progress += 0.5
   animationProgress.rightAnchor.accessibilityActivate()
   animationProgress.tintColor = .dbbSearchBarBackgroundColor()

   animationProgress.setProgress(prog, animated: true)
   perform(#selector(updateProgress), with: nil, afterDelay: 1.0)
   animationProgress.frame = CGRect(x: 0, y: 0, width: prog, height: 85)
   animationProgress.transform = animationProgress.transform.scaledBy(x: 1, y: 85)
   self.contentView.addSubview(animationProgress)

Actual tableview cell : actual_tableview_cell

Progress view getting overlapped : progressview_overlap

  • Can you add a picture of the cell so we can see what the issue is? You're either messing up the frames so that things overlap or you have to bring the text label in front of the progress bar view using the [bringSubviewToFront](https://developer.apple.com/documentation/uikit/uiview/1622541-bringsubviewtofront). – Majster Apr 23 '20 at 12:51
  • Updated the question. Thanks! – Ashwini Rao Apr 24 '20 at 05:33
  • Do you add subviews in correct order? – mahan Apr 24 '20 at 05:36

1 Answers1

1

The issue you're having is related to the order of subviews. I'm not sure what cell you are you using how and when do you add other labels. But it looks like you need to send the UIProgressView to the back.

In your case the fix should be after calling self.contentView.addSubview(animationProgress) make sure to send the subview to the back which means calling self.contentView.sendSubviewToBack(animationProgress).

Majster
  • 3,611
  • 5
  • 38
  • 60