added isEnabled func.

This commit is contained in:
Kevin G Christiano 2019-10-08 13:15:10 -04:00
parent ec190a28bd
commit 03f12b8a7a

View File

@ -62,7 +62,7 @@ import MVMCore
private var shapeLayer: CAShapeLayer?
/// Width of the check mark.
public var checkWidth: CGFloat = 2 {
public var checkWidth: CGFloat = 2.3 {
didSet {
if let shapeLayer = shapeLayer {
CATransaction.withDisabledAnimations {
@ -75,11 +75,7 @@ import MVMCore
/// Color of the check mark.
public var checkColor: UIColor = .black {
didSet {
if let shapeLayer = shapeLayer {
CATransaction.withDisabledAnimations {
shapeLayer.strokeColor = checkColor.cgColor
}
}
setshapeLayerStrokeColor(checkColor)
}
}
@ -285,7 +281,7 @@ import MVMCore
self.shapeLayer?.strokeEnd = isSelected ? 1 : 0
}
self.backgroundColor = isSelected ? self.checkedBackgroundColor : self.unCheckedBackgroundColor
backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor
}
}
@ -297,6 +293,32 @@ import MVMCore
}
}
func isEnabled(_ enabled: Bool) {
isUserInteractionEnabled = enabled
if enabled {
layer.borderColor = borderColor.cgColor
backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor
alpha = 1.0
setshapeLayerStrokeColor(checkColor)
} else {
layer.borderColor = UIColor.mfSilver().cgColor
backgroundColor = .white
alpha = DisableOppacity
setshapeLayerStrokeColor(UIColor.mfSilver())
}
}
private func setshapeLayerStrokeColor(_ color: UIColor) {
if let shapeLayer = shapeLayer {
CATransaction.withDisabledAnimations {
shapeLayer.strokeColor = color.cgColor
}
}
}
//--------------------------------------------------
// MARK: - UITouch
//--------------------------------------------------