Releases: layoutBox/PinLayout
Fix iOS extension target compilation
View build details and download artifacts on buddybuild:
PinLayout (iOS, PinLayout)
Implementation of aspectRatio methods
-
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)
Add new method "margin(_ insets: UIEdgeInsets)"
- Add new margin method
margin(_ insets: UIEdgeInsets)
Set all margins using an UIEdgeInsets.
This method is particularly useful to set all margins using iOS 11 UIView.safeAreaInsets
View build details and download artifacts on buddybuild:
PinLayout (iOS, PinLayout)
PinLayoutTVOS (iOS, PinLayoutTVOS)
Update hCenter(CGFloat), hCenter(percent), vCenter(CGFloat), vCenter(percent)
Breaking change related to hCenter(CGFloat), hCenter(percent), vCenter(CGFloat), vCenter(percent):
vCenter(_ value: CGFloat)
andvCenter(_ percent: Percent)
:
The value specifies the distance vertically of the view's center related to the superview's center in pixels. Previously it was related to the superview's top edge.hCenter(_ value: CGFloat)
andhCenter(_ percent: Percent)
:
The value specifies the distance horizontally of the view's center related to the superview's center in pixels. Previously it was related to the superview's left edge.
Previously hCenter(0)
wasn't equal to hCenter()
, same thing for vCenter(0)
. But this was an exception: top(0)
== top()
, left(0)
== left()
, right(0)
== right()
. Now thay all have the same logic.
Add methods hCenter(to edge:) and vCenter(to edge:)
- Add methods to pin hCenter and vCenter to any other view's edges (including the new hCenter and vCenter edges)
- New methods:
- func hCenter(to edge: HorizontalEdge) -> PinLayout
- func vCenter(to edge: VerticalEdge) -> PinLayout
- New UIView's edges:
- UIView.edge.hCenter
- UIView.edge.vCenter
- New methods:
View build details and download artifacts on buddybuild:
PinLayout (iOS, PinLayout)
PinLayoutTVOS (iOS, PinLayoutTVOS)
Warnings now display more context information
*Warnings now display more context information:
-
The class name of the view being layouted.
-
The view's current frame
-
The class name of all its superviews
-
The view's Tag
Examples:
-
👉 PinLayout Warning: width(50.0%) won't be applied, the view (UIView) must be added as a sub-view before being layouted using this method.
(Layouted view info: Type: UIView, Frame: (10.0, 10.0, 20.0, 30.0), Tag: 0) -
👉 PinLayout Warning: width(-20.0) won't be applied, the width (-20.0) must be greater than or equal to zero.
(Layouted view info: Type: ItemButton, Frame: (140.0, 100.0, 100.0, 60.0), Superviews: HomeView -> UIView, Tag: 0) -
👉 PinLayout Warning: topLeft(to: .topLeft, of: (UIView, Frame: (10.0, 10.0, 10.0, 10.0))) won't be applied, the reference view (UIView, Frame: (10.0, 10.0, 10.0, 10.0)) must be added as a sub-view before being used as a reference.
(Layouted view info: Type: UIView, Frame: (140.0, 100.0, 100.0, 60.0), Superviews: UIView -> UIView, Tag: 0)
-
View build details and download artifacts on buddybuild:
PinLayoutTVOS (iOS, PinLayoutTVOS)
PinLayoutSample (iOS, PinLayoutSample)
PinLayout (iOS, PinLayout)
Added a new method fitSize() + sizeThatFit() is now deprecated
- Added a new method
fitSize()
that will replace thesizeThatFit()
method. Its prior name was creating confusion with the already existingUIView.sizeToFit()` method. sizeThatFit()
method has been marked as deprecated.
Swift 4.0 support
Change
Add Swift 4.0 support
Add left to right (LTR) and right to left (RTL) language support
Change
-
Breaking change related to the following anchor's name. The change makes these anchor's name more standard:
- UIView.anchors.leftCenter has been renamed UIView.anchors.centerLeft
- UIView.anchors.rightCenter has been renamed UIView.anchors.centerRight
-
Add left to right (LTR) and right to left (RTL) language support.
Additions:- Pin.layoutDirection(_ direction: LayoutDirection)
- start(), start(_ value: CGFloat), start(_ percent: Percent)
- end(), end(_ value: CGFloat), end(_ percent: Percent)
- UIView.edge.start
- UIView.edge.end
- UIView.anchor.topStart
- UIView.anchor.topEnd
- UIView.anchor.centerStart
- UIView.anchor.centerEnd
- UIView.anchor.bottomStart
- UIView.anchor.bottomEnd
- topStart(to anchor: Anchor), topStart()
- topEnd(to anchor: Anchor), topEnd()
- centerStart(to anchor: Anchor), centerStart()
- centerEnd(to anchor: Anchor), centerEnd()
- bottomStart(to anchor: Anchor), bottomStart()
- bottomEnd(to anchor: Anchor), bottomEnd()
- before(of: UIView), before(of: [UIView])
- before(of: UIView, aligned: VerticalAlign), before(of: [UIView], aligned: VerticalAlign)
- after(of: UIView), after(of: [UIView])
- after(of: UIView, aligned: VerticalAlign), after(of: [UIView], aligned: VerticalAlign)
- marginStart(_ value: CGFloat)
- marginEnd(_ value: CGFloat)
- HorizontalAlign.start
- HorizontalAlign.end
View build details and download artifacts on buddybuild:
PinLayout (iOS, PinLayout)
PinLayoutSample (iOS, PinLayoutSample)
PinLayoutTVOS (iOS, PinLayoutTVOS)