Files
yoga/docs/_docs/api/yogakit.md
Dustin Shahidehpour 4f6924a0c1 BREAKING CHANGE: rename applyLayout to applyLayoutPreservingOrigin.
Summary: Will update on Monday

Reviewed By: emilsjolander

Differential Revision: D4545786

fbshipit-source-id: f8189d82f1c64cd1eac532fd2dfaa9aea35d6004
2017-02-11 11:26:07 -08:00

1.5 KiB

docid, title, layout, permalink
docid title layout permalink
yogakit YogaKit docs /docs/api/yogakit/

The YogaKit API is still in rapid development. Please use it and report issues, bugs or feedback.

YogaKit is a Objective-C (and Swift-compatible) wrapper for Yoga. It allows iOS Developers to manage the layout of their views using the power of Yoga.

Layout configuration is done via the YGLayout object. YogaKit exposes YGLayout via a category on UIView.

Lifecycle

As with any UIView, instantiate it using -(instancetype)initWithFrame:(CGRect)frame. YogaKit uses the frame of the parent view to determine the space that is available for children in layout.

Children

Yoga relies on UIView subviews to build up its internal layout tree. However, a subview can exclude itself from layout by setting the isIncludedInLayout property on YGLayout to NO.

It is also possible to query the number of children included in layout via numberOfChildren.

Layout

To apply a layout to a view (and its' subviews) you need to call [view.yoga applyLayoutPreservingOrigin:NO]. This will do a layout calculation (if needed) and apply the calculated frames to every view included in the layout.

In the event that you need to another layout pass on a view you can mark it dirty via [view.yoga markDirty].