繁体   English   中英

向 UITableViewCell 添加进度视图

[英]Add progress view to UITableViewCell

我想在表格视图单元格中显示文件的上传进度。 我正在以编程方式使用进度视图。 但是,进度视图与文件名及其相关数据重叠。 如何使进度视图显示在文本后面?

以下是使用的代码:

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

进度视图重叠: 进度视图重叠

您遇到的问题与子视图的顺序有关。 我不确定您使用的是哪个单元格,您如何以及何时添加其他标签。 但是看起来您需要将UIProgressView发送到后面。

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

暂无
暂无

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

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