updated debug layer
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
31975f4e19
commit
30951b6fc0
@ -122,11 +122,37 @@ extension UIView {
|
||||
extension UIView {
|
||||
public func debugBorder(show shouldShow: Bool = true, color: UIColor = .red) {
|
||||
if shouldShow {
|
||||
layer.borderColor = color.cgColor
|
||||
layer.borderWidth = VDSFormControls.widthBorder
|
||||
let borderLayer = CALayer()
|
||||
borderLayer.name = "debugAreaLayer"
|
||||
borderLayer.frame = bounds
|
||||
borderLayer.bounds = bounds
|
||||
borderLayer.borderWidth = VDSFormControls.widthBorder
|
||||
borderLayer.borderColor = color.cgColor
|
||||
layer.addSublayer(borderLayer)
|
||||
|
||||
if type(of: self) is AppleGuidlinesTouchable.Type {
|
||||
let faultToleranceX: CGFloat = max((45 - bounds.size.width) / 2.0, 0)
|
||||
let faultToleranceY: CGFloat = max((45 - bounds.size.height) / 2.0, 0)
|
||||
|
||||
let touchableAreaPath = UIBezierPath(rect: bounds.insetBy(dx: -faultToleranceX, dy: -faultToleranceY))
|
||||
let touchLayer = CAShapeLayer()
|
||||
touchLayer.path = touchableAreaPath.cgPath
|
||||
touchLayer.strokeColor = color.cgColor
|
||||
touchLayer.fillColor = UIColor.clear.cgColor
|
||||
touchLayer.lineWidth = VDSFormControls.widthBorder
|
||||
touchLayer.opacity = 1.0
|
||||
touchLayer.name = "debugTouchableAreaLayer"
|
||||
touchLayer.zPosition = 100
|
||||
touchLayer.frame = bounds
|
||||
touchLayer.bounds = bounds
|
||||
layer.addSublayer(touchLayer)
|
||||
}
|
||||
} else {
|
||||
layer.borderColor = UIColor.clear.cgColor
|
||||
layer.borderWidth = 0
|
||||
layer.sublayers?.forEach({ layer in
|
||||
if layer.name?.hasPrefix("debug") ?? false {
|
||||
layer.removeFromSuperlayer()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user