ProgreessBar Modifications
This commit is contained in:
parent
d535e9190b
commit
145cafbc30
@ -11,23 +11,21 @@ import Foundation
|
||||
public class ProgressBar: UIProgressView {
|
||||
|
||||
var isRounded = Bool()
|
||||
var thickness : Float {
|
||||
get {
|
||||
return 10
|
||||
}
|
||||
set {
|
||||
var thickness : Float = 0.0 {
|
||||
willSet(newValue) {
|
||||
heightAnchor.constraint(equalToConstant: CGFloat(newValue)).isActive = true
|
||||
switch isRounded {
|
||||
case true:
|
||||
progressViewStyle = .bar
|
||||
default:
|
||||
layer.cornerRadius = CGFloat((newValue ?? Float(0.0))/2)
|
||||
clipsToBounds = true
|
||||
default:
|
||||
progressViewStyle = .bar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, 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
|
||||
@ -45,10 +43,6 @@ public class ProgressBar: UIProgressView {
|
||||
trackTintColor = UIColor.mfGet(forHex: backgroundcolor)
|
||||
}
|
||||
}
|
||||
|
||||
if let barStyleUnwrapped = json?["barStyle"] as? Bool {
|
||||
isRounded = barStyleUnwrapped
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,9 +47,9 @@ import UIKit
|
||||
|
||||
topleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
||||
topleftlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
|
||||
let topleftconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
|
||||
topleftconstraint.priority = UILayoutPriority(rawValue: 100)
|
||||
topleftconstraint.isActive = true
|
||||
let topleftwidthconstraint = NSLayoutConstraint(item: topleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
|
||||
topleftwidthconstraint.priority = UILayoutPriority(100)
|
||||
topleftwidthconstraint.isActive = true
|
||||
topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal)
|
||||
topleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical)
|
||||
|
||||
@ -57,7 +57,7 @@ import UIKit
|
||||
toprightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
||||
toprightlabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
|
||||
toprightlabel.textAlignment = .right
|
||||
toprightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal)
|
||||
toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal)
|
||||
toprightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical)
|
||||
|
||||
var topconstraint = progress.topAnchor.constraint(equalTo: topleftlabel.bottomAnchor, constant: PaddingTwo)
|
||||
@ -74,18 +74,18 @@ import UIKit
|
||||
|
||||
bottomleftlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true
|
||||
bottomleftlabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
||||
let bottomleftconstraint = NSLayoutConstraint(item: bottomleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
|
||||
bottomleftconstraint.priority = UILayoutPriority(100)
|
||||
bottomleftconstraint.isActive = true
|
||||
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(900), for: .horizontal)
|
||||
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(850), for: .vertical)
|
||||
let bottomleftwidthconstraint = NSLayoutConstraint(item: bottomleftlabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.5, constant: 0.0)
|
||||
bottomleftwidthconstraint.priority = UILayoutPriority(100)
|
||||
bottomleftwidthconstraint.isActive = true
|
||||
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .horizontal)
|
||||
bottomleftlabel.setContentHuggingPriority(UILayoutPriority(801), for: .vertical)
|
||||
|
||||
NSLayoutConstraint(item: bottomrightlabel, attribute: .leading, relatedBy: .equal, toItem: bottomleftlabel, attribute: .trailing, multiplier: 1.0, constant: PaddingTwo).isActive = true
|
||||
bottomrightlabel.topAnchor.constraint(equalTo: progress.bottomAnchor, constant: PaddingTwo).isActive = true
|
||||
bottomrightlabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
||||
bottomrightlabel.textAlignment = .right
|
||||
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(1000), for: .horizontal)
|
||||
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(851), for: .vertical)
|
||||
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .horizontal)
|
||||
bottomrightlabel.setContentHuggingPriority(UILayoutPriority(802), for: .vertical)
|
||||
|
||||
var bottomconstraint = bottomAnchor.constraint(equalTo: bottomleftlabel.bottomAnchor, constant: PaddingTwo)
|
||||
bottomconstraint.priority = UILayoutPriority(249)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user