vds_ios/VDS/Extensions/NSLayoutDimension.swift
Matt Bruce 342357820f refactored out extensions into files
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-06-15 10:39:42 -05:00

85 lines
3.1 KiB
Swift

//
// NSLayoutDimension.swift
// VDS
//
// Created by Matt Bruce on 6/15/23.
//
import Foundation
import UIKit
//--------------------------------------------------
// MARK: - NSLayoutDimension
//--------------------------------------------------
extension NSLayoutDimension {
// These methods return an inactive constraint of the form thisVariable = constant.
@discardableResult
@objc public func constraint(equalToConstant c: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(equalToConstant: c)
lc.identifier = identifier
return lc
}
@discardableResult
@objc public func constraint(greaterThanOrEqualToConstant c: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(greaterThanOrEqualToConstant: c)
lc.identifier = identifier
return lc
}
@discardableResult
@objc public func constraint(lessThanOrEqualToConstant c: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(lessThanOrEqualToConstant: c)
lc.identifier = identifier
return lc
}
// These methods return an inactive constraint of the form thisAnchor = otherAnchor * multiplier.
@discardableResult
@objc public func constraint(equalTo anchor: NSLayoutDimension, multiplier m: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(equalTo: anchor, multiplier: m)
lc.identifier = identifier
return lc
}
@discardableResult
@objc public func constraint(greaterThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(greaterThanOrEqualTo: anchor ,multiplier: m)
lc.identifier = identifier
return lc
}
@discardableResult
@objc public func constraint(lessThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(lessThanOrEqualTo: anchor, multiplier: m)
lc.identifier = identifier
return lc
}
// These methods return an inactive constraint of the form thisAnchor = otherAnchor * multiplier + constant.
@discardableResult
@objc public func constraint(equalTo anchor: NSLayoutDimension, multiplier m: CGFloat, constant c: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(equalTo: anchor, multiplier: m, constant: c)
lc.identifier = identifier
return lc
}
@discardableResult
@objc public func constraint(greaterThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, constant c: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(greaterThanOrEqualTo: anchor, multiplier: m, constant: c)
lc.identifier = identifier
return lc
}
@discardableResult
@objc public func constraint(lessThanOrEqualTo anchor: NSLayoutDimension, multiplier m: CGFloat, constant c: CGFloat, identifier: String) -> NSLayoutConstraint {
let lc = constraint(lessThanOrEqualTo: anchor, multiplier: m, constant: c)
lc.identifier = identifier
return lc
}
}