Skip to content

Implementation of aspectRatio methods

Compare
Choose a tag to compare
@lucdion lucdion released this 29 Sep 22:39
· 654 commits to master since this release
  • Add aspectRatio methods:

    • aspectRatio(_ ratio: CGFloat):
      Set the view aspect ratio. If a single dimension is set (either width or height), the aspect ratio will be used to compute the other dimension.
      • AspectRatio is defined as the ratio between the width and the height (width / height).
      • An aspect ratio of 2 means the width is twice the size of the height.
      • AspectRatio respects the min (minWidth/minHeight) and the max (maxWidth/maxHeight) dimensions of an item.
        Set all margins using an UIEdgeInsets.
        This method is particularly useful to set all margins using iOS 11 UIView.safeAreaInsets
    • aspectRatio(of view: UIView):
      Set the view aspect ratio using another UIView's aspect ratio.

    AspectRatio is applied only if a single dimension (either width or height) can be determined,
    in that case the aspect ratio will be used to compute the other dimension.

    • AspectRatio is defined as the ratio between the width and the height (width / height).
    • AspectRatio respects the min (minWidth/minHeight) and the max (maxWidth/maxHeight)
      dimensions of an item.
  • aspectRatio():
    If the layouted view is an UIImageView, this method will set the aspectRatio using
    the UIImageView's image dimension.

    For other types of views, this method as no impact.

View build details and download artifacts on buddybuild:
PinLayout (iOS, PinLayout)
PinLayoutTVOS (iOS, PinLayoutTVOS)