constraints added. changes made.

This commit is contained in:
Kevin G Christiano 2019-10-17 11:57:30 -04:00
parent 5ef9754e2c
commit f267b98438

View File

@ -75,7 +75,7 @@ import MVMCore
/// Color of the check mark.
public var checkColor: UIColor = .black {
didSet {
setshapeLayerStrokeColor(checkColor)
setShapeLayerStrokeColor(checkColor)
}
}
@ -115,6 +115,21 @@ import MVMCore
}
}
//--------------------------------------------------
// MARK: - Constraints
//--------------------------------------------------
private var heightConstraint: NSLayoutConstraint?
private var widthConstraint: NSLayoutConstraint?
/// Updates the height and width anchors of the Checkbox with the assigned value.
public var heigthWidthConstant: Int = Checkbox.defaultHeightWidth {
didSet {
heightConstraint?.constant = heigthWidthConstant
widthConstraint?.constant = heigthWidthConstant
}
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
@ -170,9 +185,15 @@ import MVMCore
open func setupView() {
guard constraints.isEmpty else { return }
isUserInteractionEnabled = true
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
widthConstraint = widthAnchor.constraint(equalToConstant: Checkbox.defaultHeightWidth)
heightConstraint = heightAnchor.constraint(equalToConstant: Checkbox.defaultHeightWidth)
heightWidthIsActive(true)
}
//--------------------------------------------------
@ -301,16 +322,16 @@ import MVMCore
layer.borderColor = borderColor.cgColor
backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor
alpha = 1.0
setshapeLayerStrokeColor(checkColor)
setShapeLayerStrokeColor(checkColor)
} else {
layer.borderColor = UIColor.mfSilver().cgColor
backgroundColor = .clear
alpha = DisableOppacity
setshapeLayerStrokeColor(UIColor.mfSilver())
setShapeLayerStrokeColor(UIColor.mfSilver())
}
}
private func setshapeLayerStrokeColor(_ color: UIColor) {
private func setShapeLayerStrokeColor(_ color: UIColor) {
if let shapeLayer = shapeLayer {
CATransaction.withDisabledAnimations {
@ -319,6 +340,12 @@ import MVMCore
}
}
public func heightWidthIsActive(_ isActive: Bool) {
heightConstraint?.isActive = isActive
widthConstraint?.isActive = isActive
}
//--------------------------------------------------
// MARK: - UITouch
//--------------------------------------------------