向 UITableViewCell 添加进度视图
Add progress view to UITableViewCell
我想在 table 视图单元格中显示文件的上传进度。
我正在以编程方式使用 Progress View。但是,进度视图与文件名及其相关数据重叠。如何让进度视图显示在文本后面?
以下是使用的代码:
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)
实际 table查看单元格:
进度视图重叠:
您遇到的问题与子视图的顺序有关。我不确定您使用的是哪个单元格,您如何以及何时添加其他标签。但是看起来你需要把 UIProgressView
发送到后面。
在你的情况下,修复应该在调用 self.contentView.addSubview(animationProgress)
之后确保将子视图发送到后面,这意味着调用 self.contentView.sendSubviewToBack(animationProgress)
.
我想在 table 视图单元格中显示文件的上传进度。 我正在以编程方式使用 Progress View。但是,进度视图与文件名及其相关数据重叠。如何让进度视图显示在文本后面?
以下是使用的代码:
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)
实际 table查看单元格:
进度视图重叠:
您遇到的问题与子视图的顺序有关。我不确定您使用的是哪个单元格,您如何以及何时添加其他标签。但是看起来你需要把 UIProgressView
发送到后面。
在你的情况下,修复应该在调用 self.contentView.addSubview(animationProgress)
之后确保将子视图发送到后面,这意味着调用 self.contentView.sendSubviewToBack(animationProgress)
.