LynxView itself is a native view that can easily be used as a full-screen view, or be embedded within a non-full-screen native view.
LynxView corresponds to the Page element. It only allows the client to set size constraints on LynxView, and you generally cannot directly modify the Page's style to set its size.
The client sets different size constraints on LynxView, which translates to setting size constraints on the Page. The Lynx layout engine uses these constraints to calculate the size of the Page node and all its child nodes.
You should proactively set its size constraints, when creating a LynxView on iOS.
There are two ways to set size constraints for LynxView.
updateViewportWithPreferredLayoutWidth
and setLayoutWidthMode、setLayoutHeightMode
to set fixed or flexible sizes.lynxviewbuilder#frame
to set fixed size.Supported constraint modes:
LynxViewSizeModeUndefined
LynxView's size is determined by Page content, with no parent constraints.
LynxViewSizeModeExact
LynxView's size is fixed, same as the Page element's size.
LynxViewSizeModeMax
LynxView's maximum width or height.
LynxViewBuilder#frame
You can set the frame
property size when creating LynxView, so the size of LynxView is fixed.
For example, if you want to fix the size of LynxView to 400x200, you can do it as follows:
preferredLayoutWidth/preferredLayoutHeight
andlayoutWidthMode/layoutHeightMode
For example:
If you want LynxView to adapt its size based on its content, you can either avoid setting LynxViewBuilder#frame
, or set setLayoutWidth/HeightMode
to LynxViewSizeModeUndefined
or LynxViewSizeModeMax
.