// // ProgressBar.swift // MVMCoreUI // // Created by Panth Patel on 5/3/19. // Copyright © 2019 Verizon Wireless. All rights reserved. // import Foundation public class ProgressBar: UIProgressView { var isRounded = Bool() var thickness : Float = 0.0 { willSet(newValue) { heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true switch isRounded { case true: layer.cornerRadius = CGFloat(newValue/2) clipsToBounds = true default: progressViewStyle = .bar } } } public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { isRounded = json?.optionalBoolForKey("roundedRect") ?? false thickness = json?.floatFromStringForKey("thickness") ?? Float(0.0) let percentage = json?.floatFromStringForKey("percent") progress = (percentage ?? Float(0.0))/100 progressTintColor = UIColor.mfBattleshipGrey() trackTintColor = UIColor.mfLighterGray() if let progresscolor = json?.optionalStringForKey("progressColor") { if !progresscolor.isEmpty { progressTintColor = UIColor.mfGet(forHex: progresscolor) } } if let backgroundcolor = json?.optionalStringForKey("backgroundColor") { if !backgroundcolor.isEmpty { trackTintColor = UIColor.mfGet(forHex: backgroundcolor) } } } }