Reputation: 47
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)
Progress view getting overlapped :
Upvotes: 1
Views: 408
Reputation: 3701
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)
.
Upvotes: 1