UIView
class UIView : UIResponder, NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem, UITraitEnvironment, UICoordinateSpace, UIFocusItem, CALayerDelegate
-
Add several types constraints
Example:
view.rk_alAdd(size: [.width(10), .height(10)], center: [.centerX(), .centerY()]) view.rk_alAdd(center: [.centerX()], edge: [.top(100), .bottom(-90)])
Declaration
Swift
@discardableResult public func rk_alAdd( size: [RKConstraintSize] = [], center: [RKConstraintCenter] = [], edge: [RKConstraintEdge] = [], baseline: [RKConstraintBaseline] = [], isActive: Bool = true) -> RKConstraints
Parameters
size
RKConstraintSize objects
center
RKConstraintCenter objects
edge
RKConstraintEdge objects
baseline
RKConstraintBaseline objects
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Add baseline constraints
Example:
view.rk_alBaseline(.firstBaseline(10), .lastBaseline(min: otherView)) view.rk_alBaseline(.firstBaseline(10), .lastBaseline(max: otherView), isActive: false)
Declaration
Swift
@discardableResult public func rk_alBaseline(_ values: RKConstraintBaseline..., isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintBaseline
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Add baseline constraints
Example:
view.rk_alBaseline(with: [.firstBaseline(10), .lastBaseline(min: otherView)]) view.rk_alBaseline(with: [.firstBaseline(10), .lastBaseline(max: otherView)], isActive: false)
Declaration
Swift
@discardableResult func rk_alBaseline(with values: [RKConstraintBaseline], isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintBaseline
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Remove all baseline constraints
Declaration
Swift
public func rk_alRemoveBaselineConstraints()
-
Remove all firstBaseline constraints
Declaration
Swift
public func rk_alRemoveFirstBaselineConstraints()
-
Remove all lastBaseline constraints
Declaration
Swift
public func rk_alRemoveLastBaselineConstraints()
-
Add center constraints
Example:
view.rk_alCenter(.centerX(10), .centerY()) view.rk_alCenter(.centerX(10), .centerY(), isActive: false)
Declaration
Swift
@discardableResult public func rk_alCenter(_ values: RKConstraintCenter..., isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintCenter
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Add center constraints
Example:
view.rk_alCenter(with: [.centerX(10), .centerY()]) view.rk_alCenter(with: [.centerX(10), .centerY()], isActive: false)
Declaration
Swift
@discardableResult func rk_alCenter(with values: [RKConstraintCenter], isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintCenter
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Constraints for centering in superview
Declaration
Swift
@discardableResult public func rk_alCenterSuperView(isActive: Bool = true) -> RKConstraints
-
Remove all center constraints
Declaration
Swift
public func rk_alRemoveCenterConstraints()
-
Remove all centerX constraints
Declaration
Swift
public func rk_alRemoveCenterXConstraints()
-
Remove all centerY constraints
Declaration
Swift
public func rk_alRemoveCenterYConstraints()
-
Add edge constraints
Example:
view.rk_alEdge(.top(10), .bottom(0)) view.rk_alEdge(.top(10), .bottom(-90), isActive: false)
Declaration
Swift
@discardableResult public func rk_alEdge(_ values: RKConstraintEdge..., isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintEdge
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Add edge constraints
Example:
view.rk_alEdge(with: [.top(10), .bottom(0)]) view.rk_alEdge(with: [.top(10), .bottom(-90)], isActive: false)
Declaration
Swift
@discardableResult func rk_alEdge(with values: [RKConstraintEdge], isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintEdge
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Add edges superview bounds
Declaration
Swift
@discardableResult public func rk_alEdgeSuperViewBounds(isActive: Bool = true) -> RKConstraints
Parameters
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Remove all edge constraints
Declaration
Swift
public func rk_alRemoveAllEdgeConstraints()
-
Remove all top constraints
Declaration
Swift
public func rk_alRemoveTopConstraints()
-
Remove all left constraints
Declaration
Swift
public func rk_alRemoveLeftConstraints()
-
Remove all bottom constraints
Declaration
Swift
public func rk_alRemoveBottomConstraints()
-
Remove all right constraints
Declaration
Swift
public func rk_alRemoveRightConstraints()
-
Remove all leading constraints
Declaration
Swift
public func rk_alRemoveLeadingConstraints()
-
Remove all trailing constraints
Declaration
Swift
public func rk_alRemoveTrailingConstraints()
-
Add size constraints
Example:
view.rk_alSize(.width(10), .height(min: otherView)) view.rk_alSize(.width(10), .height(max: otherView), isActive: false)
Declaration
Swift
@discardableResult public func rk_alSize(_ values: RKConstraintSize..., isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintSize
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Add size constraints
Example:
view.rk_alSize(with: [.width(10), .height(min: otherView)]) view.rk_alSize(with: [.width(10), .height(max: otherView)], isActive: false)
Declaration
Swift
@discardableResult func rk_alSize(with values: [RKConstraintSize], isActive: Bool = true) -> RKConstraints
Parameters
values
List RKConstraintSize
isActive
true, if constraints must be activated, otherwise false
Return Value
RKConstraints
-
Remove all size constraints
Declaration
Swift
public func rk_alRemoveSizeConstraints()
-
Remove all height constraints
Declaration
Swift
public func rk_alRemoveSizeHeightConstraints()
-
Remove all width constraints
Declaration
Swift
public func rk_alRemoveSizeWidthConstraints()
-
Return
- safeAreaLayoutGuide for >= iOS 11
- layoutMarginsGuide for < iOS 11
Declaration
Swift
@available(iOS 9, *) public var rkSafeAreaLayoutGuide: UILayoutGuide { get }
-
Return
- safeAreaInsets for >= iOS 11
- UIEdgeInsets(top: x, left: 0, bottom: y, right: 0) for < iOS 11
where:
- x – maxY for NavigationBar or maxY for StatusBar
- y – minY for TabBar
Declaration
Swift
@available(iOS 8, *) public var rkSafeAreaInsets: UIEdgeInsets { get }