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