refactored more anchors
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
b80be084ce
commit
6604036bf7
@ -258,18 +258,11 @@ open class BadgeIndicator: View {
|
|||||||
badgeView.addSubview(label)
|
badgeView.addSubview(label)
|
||||||
accessibilityElements = [label]
|
accessibilityElements = [label]
|
||||||
|
|
||||||
heightConstraint = badgeView.heightAnchor.constraint(greaterThanOrEqualToConstant: badgeSize)
|
heightConstraint = badgeView.heightGreaterThanEqualTo(constant: badgeSize)
|
||||||
heightConstraint?.isActive = true
|
widthConstraint = badgeView.widthGreaterThanEqualTo(constant: badgeSize)
|
||||||
|
|
||||||
widthConstraint = badgeView.widthAnchor.constraint(greaterThanOrEqualToConstant: badgeSize)
|
|
||||||
widthConstraint?.isActive = true
|
|
||||||
|
|
||||||
//we are insetting the padding to compensate for the border
|
//we are insetting the padding to compensate for the border
|
||||||
NSLayoutConstraint.activate([
|
badgeView.pinToSuperView(.init(top: borderWidth, left: borderWidth, bottom: borderWidth, right: borderWidth))
|
||||||
badgeView.topAnchor.constraint(equalTo: topAnchor, constant: borderWidth),
|
|
||||||
badgeView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -borderWidth),
|
|
||||||
badgeView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: borderWidth),
|
|
||||||
badgeView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -borderWidth)])
|
|
||||||
|
|
||||||
labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: badgeView.topAnchor)
|
labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: badgeView.topAnchor)
|
||||||
labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: badgeView.bottomAnchor)
|
labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: badgeView.bottomAnchor)
|
||||||
|
|||||||
@ -235,22 +235,17 @@ open class ButtonIcon: Control {
|
|||||||
addSubview(icon)
|
addSubview(icon)
|
||||||
|
|
||||||
//determines the height/width of the icon
|
//determines the height/width of the icon
|
||||||
layoutGuideWidthConstraint = iconLayoutGuide.widthAnchor.constraint(equalToConstant: size.containerSize)
|
layoutGuideWidthConstraint = iconLayoutGuide.width(constant: size.containerSize)
|
||||||
layoutGuideHeightConstraint = iconLayoutGuide.heightAnchor.constraint(equalToConstant: size.containerSize)
|
layoutGuideHeightConstraint = iconLayoutGuide.height(constant: size.containerSize)
|
||||||
|
|
||||||
|
//pin layout guide
|
||||||
|
iconLayoutGuide.pinToOwningView()
|
||||||
|
|
||||||
//determines the center point of the icon
|
//determines the center point of the icon
|
||||||
centerXConstraint = icon.centerXAnchor.constraint(equalTo: iconLayoutGuide.centerXAnchor, constant: 0)
|
centerXConstraint = icon.centerXAnchor.constraint(equalTo: iconLayoutGuide.centerXAnchor, constant: 0)
|
||||||
|
centerXConstraint?.activate()
|
||||||
centerYConstraint = icon.centerYAnchor.constraint(equalTo: iconLayoutGuide.centerYAnchor, constant: 0)
|
centerYConstraint = icon.centerYAnchor.constraint(equalTo: iconLayoutGuide.centerYAnchor, constant: 0)
|
||||||
|
centerYConstraint?.activate()
|
||||||
//activate the constraints
|
|
||||||
NSLayoutConstraint.activate([layoutGuideWidthConstraint!,
|
|
||||||
layoutGuideHeightConstraint!,
|
|
||||||
centerXConstraint!,
|
|
||||||
centerYConstraint!,
|
|
||||||
iconLayoutGuide.topAnchor.constraint(equalTo: topAnchor),
|
|
||||||
iconLayoutGuide.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
||||||
iconLayoutGuide.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
||||||
iconLayoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor)])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets to default settings.
|
/// Resets to default settings.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user