CPCFixedAspectRatioView

public protocol CPCFixedAspectRatioView : CPCViewMeasuring

A view type that sizes instances using linear equation.

  • Tuple representing multiplier K and constant C of a linear equation.

    Declaration

    Swift

    typealias AspectRatio = (multiplier: CGFloat, constant: CGFloat)
  • Returns coefficients of equation ViewHeight = K x ViewWidth + C to fit content.

    Declaration

    Swift

    static func aspectRatioComponents(for attributes: LayoutAttributes) -> AspectRatio?

    Parameters

    attributes

    View-specific layout attributes to perform layout calculations.

    Return Value

    Multiplier K and constant C.

  • Initialize NSLayoutConstraint expressing dependency between view dimensions.

    Declaration

    Swift

    public func aspectRatioLayoutConstraint(for attributes: LayoutAttributes) -> NSLayoutConstraint

    Parameters

    attributes

    Attributes for which instance aspect ratio is calculated.

    Return Value

    A new NSLayoutConstraint that ensures adequate sizing of this view.