borders.
This commit is contained in:
parent
b032e40400
commit
5f8780614f
@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
|
/**
|
||||||
|
This class expects its height and width to be equal.
|
||||||
|
*/
|
||||||
@objcMembers open class Checkbox: UIControl, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol {
|
@objcMembers open class Checkbox: UIControl, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -41,23 +43,8 @@ import MVMCore
|
|||||||
|
|
||||||
public var lineWidth: CGFloat = 2
|
public var lineWidth: CGFloat = 2
|
||||||
public var lineColor: UIColor = .black
|
public var lineColor: UIColor = .black
|
||||||
|
public var borderColor: UIColor = .black
|
||||||
open var borderColor: UIColor {
|
public var borderWidth: CGFloat = 1
|
||||||
get {
|
|
||||||
guard let color = layer.borderColor else { return .black }
|
|
||||||
return UIColor(cgColor: color)
|
|
||||||
}
|
|
||||||
set (newColor) {
|
|
||||||
layer.borderColor = newColor.cgColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open var borderWidth: CGFloat {
|
|
||||||
get { return layer.borderWidth }
|
|
||||||
set (newWidth) {
|
|
||||||
layer.borderWidth = newWidth
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override open var isSelected: Bool {
|
override open var isSelected: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
@ -141,15 +128,15 @@ import MVMCore
|
|||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
drawCheck()
|
drawCheck()
|
||||||
layer.cornerRadius = hasRoundedCorners ? cornerRadiusValue : 0
|
layer.cornerRadius = hasRoundedCorners ? cornerRadiusValue : 0
|
||||||
backgroundColor = unCheckedBackgroundColor ?? .white
|
backgroundColor = unCheckedBackgroundColor
|
||||||
|
layer.borderWidth = borderWidth
|
||||||
|
layer.borderColor = borderColor.cgColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public func setupView() {
|
public func setupView() {
|
||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
layer.borderWidth = 1
|
|
||||||
layer.borderColor = UIColor.black.cgColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user