progress_bar changes
This commit is contained in:
parent
1b116485e4
commit
350385a499
@ -10,7 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
public class ProgressBar: UIProgressView {
|
public class ProgressBar: UIProgressView {
|
||||||
|
|
||||||
public func styleprogessbar(json: Dictionary<String,Any>) -> UIProgressView {
|
public func styleprogessbar(json: Dictionary<String,Any>) {
|
||||||
let percentage = Float(json["percent"] as! String)
|
let percentage = Float(json["percent"] as! String)
|
||||||
let barstyle = json["barStyle"] as! Bool
|
let barstyle = json["barStyle"] as! Bool
|
||||||
let progresscolor = json["progressColor"] as! String
|
let progresscolor = json["progressColor"] as! String
|
||||||
@ -29,7 +29,6 @@ public class ProgressBar: UIProgressView {
|
|||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import UIKit
|
|||||||
|
|
||||||
var progress = ProgressBar()
|
var progress = ProgressBar()
|
||||||
var descriptionLabel = Label()
|
var descriptionLabel = Label()
|
||||||
|
var thickness: Float?
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
@ -29,12 +30,6 @@ import UIKit
|
|||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
|
|
||||||
// super.init(frame: CGRect(x:0, y:0, width:400, height:80))
|
|
||||||
// setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
open override func needsToBeConstrained() -> Bool {
|
open override func needsToBeConstrained() -> Bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -43,135 +38,40 @@ import UIKit
|
|||||||
|
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|
||||||
progress.styleprogessbar(json: json as! Dictionary<String, Any>)
|
if let jsonUnwrapped = json as? Dictionary<String, Any> {
|
||||||
|
progress.styleprogessbar(json: jsonUnwrapped)
|
||||||
|
}
|
||||||
|
|
||||||
let textlabeljson = json!["label"] as! Dictionary<String,Any> //UILabel.init(frame: CGRect(x:0, y:0, width: 300, height: 300))
|
let textlabeljson = json!["label"] as! Dictionary<String,Any> //UILabel.init(frame: CGRect(x:0, y:0, width: 300, height: 300))
|
||||||
self.descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData)
|
self.descriptionLabel.setWithJSON(textlabeljson, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
let thickness = Float(json!["thickness"] as! String)
|
thickness = Float(json!["thickness"] as! String)
|
||||||
|
// thickness = 20.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// let leadingconstraint = NSLayoutConstraint(item: progressUI,
|
|
||||||
// attribute: .leading,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: self,
|
|
||||||
// attribute: .leading,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 20)
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// let topconstraint = NSLayoutConstraint(item: progressUI,
|
|
||||||
// attribute: .top,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: self,
|
|
||||||
// attribute: .top,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 0)
|
|
||||||
// let widthconstraint = NSLayoutConstraint(item: progressUI,
|
|
||||||
// attribute: .width,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: nil,
|
|
||||||
// attribute: .notAnAttribute,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 350)
|
|
||||||
NSLayoutConstraint(item: progress,
|
|
||||||
attribute: .height,
|
|
||||||
relatedBy: .equal,
|
|
||||||
toItem: nil,
|
|
||||||
attribute: .notAnAttribute,
|
|
||||||
multiplier: 1,
|
|
||||||
constant: (CGFloat(thickness!)))
|
|
||||||
|
|
||||||
// progressUI.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true
|
|
||||||
|
|
||||||
// self.addConstraints([leadingconstraint, topconstraint, widthconstraint, heightconstraint])
|
|
||||||
// self.backgroundColor = .blue
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override open func setupView() {
|
override open func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
self.addSubview(descriptionLabel)
|
addSubview(descriptionLabel)
|
||||||
addSubview(progress)
|
addSubview(progress)
|
||||||
|
|
||||||
progress.translatesAutoresizingMaskIntoConstraints = false
|
progress.translatesAutoresizingMaskIntoConstraints = false
|
||||||
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
|
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
// descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: 25).isActive = true
|
|
||||||
// descriptionLabel.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true
|
|
||||||
// descriptionLabel.heightAnchor.constraint(equalTo: self.heightAnchor).isActive = true
|
|
||||||
|
|
||||||
let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth()
|
let vericalSpacing = MFStyler.defaultVerticalPaddingForApplicationWidth()
|
||||||
let horizontalSpacing = MFStyler.defaultHorizontalPaddingForApplicationWidth()
|
|
||||||
|
|
||||||
// let leadingconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
||||||
// attribute: .leading,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: self,
|
|
||||||
// attribute: .leading,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 20)
|
|
||||||
//
|
|
||||||
// let trailingconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
||||||
// attribute: .trailing,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: self,
|
|
||||||
// attribute: .trailing,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 20)
|
|
||||||
descriptionLabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
descriptionLabel.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
||||||
descriptionLabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
descriptionLabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
||||||
|
descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
|
||||||
descriptionLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: vericalSpacing).isActive = true
|
descriptionLabel.numberOfLines = 0
|
||||||
descriptionLabel.bottomAnchor.constraint(equalTo: progress.topAnchor, constant: vericalSpacing).isActive = true
|
descriptionLabel.sizeToFit()
|
||||||
|
|
||||||
|
|
||||||
progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
progress.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
|
||||||
progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
progress.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
|
||||||
progress.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: vericalSpacing).isActive = true
|
progress.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
||||||
// progress.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: vericalSpacing).isActive = true
|
progress.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: vericalSpacing).isActive = true
|
||||||
|
progress.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* let topconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
||||||
attribute: .top,
|
|
||||||
relatedBy: .equal,
|
|
||||||
toItem: self,
|
|
||||||
attribute: .top,
|
|
||||||
multiplier: 1,
|
|
||||||
constant: 0) */
|
|
||||||
|
|
||||||
// let bottomconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
||||||
// attribute: .bottom,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: self,
|
|
||||||
// attribute: .bottom,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 1)
|
|
||||||
|
|
||||||
// NSLayoutConstraint.constraintPinSubview(descriptionLabel, pinCenterX: true, pinCenterY: false)
|
|
||||||
// NSLayoutConstraint.constraintPinSubview(descriptionLabel, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true)
|
|
||||||
// let widthconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
||||||
// attribute: .width,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: nil,
|
|
||||||
// attribute: .width,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 350)
|
|
||||||
//
|
|
||||||
// let heightconstraint = NSLayoutConstraint(item: descriptionLabel,
|
|
||||||
// attribute: .height,
|
|
||||||
// relatedBy: .equal,
|
|
||||||
// toItem: nil,
|
|
||||||
// attribute: .height,
|
|
||||||
// multiplier: 1,
|
|
||||||
// constant: 30)
|
|
||||||
|
|
||||||
// self.addConstraints([leadingconstraint,trailingconstraint])
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user