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

  • 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
  • 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

  • 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

  • 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 }