我想获取标签中的下载百分比。我使用这段代码:
cell.label?.text = "\( (CGFloat(totalBytesWritten) / CGFloat(totalBytesExpectedToWrite)) * 100)"
但在这种情况下,我得到了点后的百分比数字。
我尝试使用不同的代码,但没有帮助:
cell.label?.text = "\( (Int(totalBytesWritten) / Int(totalBytesExpectedToWrite)) * 100)"
如何获得这样的百分比 98%
而不是这样的 98.5353457%
?
最佳答案
尝试 Int(CGFloat(totalBytesWritten)/CGFloat(totalBytesExpectedToWrite) * 100.0)
关于ios - swift:下载百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51386095/