Further updates made.
This commit is contained in:
parent
bbdb2181f2
commit
ec190a28bd
@ -8,22 +8,6 @@
|
|||||||
|
|
||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
/*
|
|
||||||
!!! -- DO NOT REMOVE -- !!!
|
|
||||||
(Unless Design changes the appearance of the checkmark).
|
|
||||||
|
|
||||||
// Offsets based on the 124x124 example checkmark
|
|
||||||
let startXOffset: Float = 42.0 / 124.0 ~~ 0.33871
|
|
||||||
let startYOffset: Float = 66.0 / 124.0 ~~ 0.53225
|
|
||||||
let pivotXOffset: Float = 58.0 / 124.0 ~~ 0.46774
|
|
||||||
let pivotYOffset: Float = 80.0 / 124.0 ~~ 0.64516
|
|
||||||
let endXOffset: Float = 83.0 / 124.0 ~~ 0.66935
|
|
||||||
let endYOffset: Float = 46.0 / 124.0 ~~ 0.37097
|
|
||||||
let pivotPercentage: Float = 0.34
|
|
||||||
let endPercentage = 1.0 - pivotPercentage
|
|
||||||
let animationInterval: Float = 0.01
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class expects its height and width to be equal.
|
This class expects its height and width to be equal.
|
||||||
*/
|
*/
|
||||||
@ -182,7 +166,7 @@ import MVMCore
|
|||||||
override open func layoutSubviews() {
|
override open func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
drawCheck()
|
drawShapeLayer()
|
||||||
layer.cornerRadius = isRound ? cornerRadiusValue : 0
|
layer.cornerRadius = isRound ? cornerRadiusValue : 0
|
||||||
layer.borderWidth = borderWidth
|
layer.borderWidth = borderWidth
|
||||||
layer.borderColor = borderColor.cgColor
|
layer.borderColor = borderColor.cgColor
|
||||||
@ -220,8 +204,8 @@ import MVMCore
|
|||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Creates the check mark used for the checkbox.
|
/// Creates the check mark layer.
|
||||||
private func drawCheck() {
|
private func drawShapeLayer() {
|
||||||
|
|
||||||
if shapeLayer == nil {
|
if shapeLayer == nil {
|
||||||
|
|
||||||
@ -241,16 +225,14 @@ import MVMCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a UIBezierPath detailing the path of a checkmark
|
/// - returns: The CGPath of a UIBezierPath detailing the path of a checkmark
|
||||||
func checkMarkPath() -> CGPath {
|
func checkMarkPath() -> CGPath {
|
||||||
|
|
||||||
let length = max(bounds.size.height, bounds.size.width)
|
let length = max(bounds.size.height, bounds.size.width)
|
||||||
let xInsetLeft = length * 0.25
|
let xInsetLeft = length * 0.25
|
||||||
let xInsetRight = length * 0.25
|
|
||||||
let yInsetTop = length * 0.3
|
let yInsetTop = length * 0.3
|
||||||
let yInsetBottom = length * 0.35
|
let innerWidth = length - (xInsetLeft + length * 0.25) // + Right X Inset
|
||||||
let innerWidth = length - (xInsetLeft + xInsetRight)
|
let innerHeight = length - (yInsetTop + length * 0.35) // + Bottom Y Inset
|
||||||
let innerHeight = length - (yInsetTop + yInsetBottom)
|
|
||||||
|
|
||||||
let startPoint = CGPoint(x: xInsetLeft, y: yInsetTop + (innerHeight / 2))
|
let startPoint = CGPoint(x: xInsetLeft, y: yInsetTop + (innerHeight / 2))
|
||||||
let pivotOffSet = CGPoint(x: xInsetLeft + (innerWidth * 0.33), y: yInsetTop + innerHeight)
|
let pivotOffSet = CGPoint(x: xInsetLeft + (innerWidth * 0.33), y: yInsetTop + innerHeight)
|
||||||
@ -274,7 +256,7 @@ import MVMCore
|
|||||||
self.updateSelectionOnly = true
|
self.updateSelectionOnly = true
|
||||||
self.isSelected = selected
|
self.isSelected = selected
|
||||||
self.updateSelectionOnly = false
|
self.updateSelectionOnly = false
|
||||||
self.drawCheck()
|
self.drawShapeLayer()
|
||||||
self.shapeLayer?.removeAllAnimations()
|
self.shapeLayer?.removeAllAnimations()
|
||||||
self.updateCheckboxUI(isSelected: selected, isAnimated: animated)
|
self.updateCheckboxUI(isSelected: selected, isAnimated: animated)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user