added isEnabled func.
This commit is contained in:
parent
ec190a28bd
commit
03f12b8a7a
@ -62,7 +62,7 @@ import MVMCore
|
|||||||
private var shapeLayer: CAShapeLayer?
|
private var shapeLayer: CAShapeLayer?
|
||||||
|
|
||||||
/// Width of the check mark.
|
/// Width of the check mark.
|
||||||
public var checkWidth: CGFloat = 2 {
|
public var checkWidth: CGFloat = 2.3 {
|
||||||
didSet {
|
didSet {
|
||||||
if let shapeLayer = shapeLayer {
|
if let shapeLayer = shapeLayer {
|
||||||
CATransaction.withDisabledAnimations {
|
CATransaction.withDisabledAnimations {
|
||||||
@ -75,11 +75,7 @@ import MVMCore
|
|||||||
/// Color of the check mark.
|
/// Color of the check mark.
|
||||||
public var checkColor: UIColor = .black {
|
public var checkColor: UIColor = .black {
|
||||||
didSet {
|
didSet {
|
||||||
if let shapeLayer = shapeLayer {
|
setshapeLayerStrokeColor(checkColor)
|
||||||
CATransaction.withDisabledAnimations {
|
|
||||||
shapeLayer.strokeColor = checkColor.cgColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +281,7 @@ import MVMCore
|
|||||||
self.shapeLayer?.strokeEnd = isSelected ? 1 : 0
|
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
|
// MARK: - UITouch
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user