ROStorageBar 是一个库,能够提供简单的方法来创建类似 iTunes Usage Bar 的 UIView。
也可以在栏的下方添加文字。
用法:
override func viewDidLoad() { super.viewDidLoad() storageBar.add(0.2, title: "Apps", color: UIColor(hex:"#FFABAB")) storageBar.add(0.15, title: "Documents", color: UIColor(hex:"#FFD29B")) storageBar.add(0.21, title: "Photos", color: UIColor(hex:"#DDEBF9")) storageBar.add(0.3, title: "Movies", color: UIColor(hex:"#c3c3c3")) // Or if you want to use directly the struct to add an item storageBar.addStorageBarValue(ROStorageBarValue(value: 0.6, title: "Backups", color: UIColor(hex:"#A8DBA8"))) storageBar.unit = "GB" storageBar.displayTitle = false storageBar.displayValue = false storageBar.displayCaption = true storageBar.titleFontSize = 10.0 storageBar.valueFontSize = 10.0 var numberFormatter = NSNumberFormatter() numberFormatter.maximumFractionDigits = 2 numberFormatter.minimumIntegerDigits = 1 storageBar.numberFormatter = numberFormatter }