简体   繁体   English

向 UITableViewCell 添加进度视图

[英]Add progress view to UITableViewCell

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:进度视图重叠: 进度视图重叠

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.但是看起来您需要将UIProgressView发送到后面。

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) .在您的情况下,修复应该在调用self.contentView.addSubview(animationProgress)之后确保将子视图发送到后面,这意味着调用self.contentView.sendSubviewToBack(animationProgress)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM