Movatterモバイル変換


[0]ホーム

URL:


FlexLayout Docs (91% documented)

View on GitHub

FlexLayout Reference Flex Class Reference

Flex

publicclassFlex

FlexLayout interface.

The interface is accessible from any UIView class instance:

   label.flex.margin(10)

Properties

  • Flex items’s UIView.

    Declaration

    Swift

    publicletview:UIView
  • Item natural size, considering only properties of the view itself. Independent of the item frame.

    Declaration

    Swift

    publicvarintrinsicSize:CGSize

Flex item addition and definition

  • This method adds a flex item (UIView) to a flex container. Internally the methods adds the UIView has subviews and enables flexbox.

    Declaration

    Swift

    publicfuncaddItem()->Flex

    Return Value

    The added view flex interface

  • This method is similar toaddItem(: UIView) except that it also creates the flex item’s UIView. Internally the method creates anUIView, adds it has subviews and enables flexbox. This is useful to add a flex item/container easily when you don’t need to refer to it later.

    Declaration

    Swift

    publicfuncaddItem(_view:UIView)->Flex

    Parameters

    view

    view to add to the flex container

    Return Value

    The added view flex interface

  • This method is used to structure your code so that it matches the flexbox structure. The method has a closure parameter with asingle parameter calledflex. This parameter is in fact, the view’s flex interface, it can be used to adds other flex itemsand containers.

    Declaration

    Swift

    publicfuncdefine(_closure:(_flex:Flex)->Void)->Flex

    Parameters

    closure

    Return Value

    Flex interface

Layout / intrinsicSize / sizeThatFits

  • The method layout the flex container’s children

    Declaration

    Swift

    publicfunclayout(mode:LayoutMode=.fitContainer)

    Parameters

    mode

    specify the layout mod (LayoutMode).

  • This property controls dynamically if a flexbox’s UIView is included or not in the flexbox layouting. When aflexbox’s UIView is excluded, FlexLayout won’t layout the view and its children views.

    Declaration

    Swift

    publicvarisIncludedInLayout:Bool=true
  • This method controls dynamically if a flexbox’s UIView is included or not in the flexbox layouting. When aflexbox’s UIView is excluded, FlexLayout won’t layout the view and its children views.

    Declaration

    Swift

    publicfuncisIncludedInLayout(_included:Bool)->Flex

    Parameters

    included

    true to layout the view

    Return Value

  • The framework is so highly optimized, that flex item are layouted only when a flex property is changed and when flex containersize change. In the event that you want to force FlexLayout to do a layout of a flex item, you can mark it as dirty usingmarkDirty().

    Dirty flag propagates to the root of the flexbox tree ensuring that when any item is invalidated its whole subtree will be re-calculated

    Declaration

    Swift

    publicfuncmarkDirty()->Flex

    Return Value

    Flex interface

  • Returns the item size when layouted in the specified frame size

    Declaration

    Swift

    publicfuncsizeThatFits(size:CGSize)->CGSize

    Parameters

    size

    frame size

    Return Value

    item size

Direction, wrap, flow

  • Thedirection property establishes the main-axis, thus defining the direction flex items are placed in the flex container.

    Thedirection property specifies how flex items are laid out in the flex container, by setting the direction of the flex container’s main axis. They can be laid out in two main directions, like columns vertically or like rows horizontally.

    Note that row and row-reverse are affected by the layout direction (seelayoutDirection property) of the flex container. If its text direction is LTR (left to right), row represents the horizontal axis oriented from left to right, and row-reverse from right to left; if the direction is rtl, it’s the opposite.

    Declaration

    Swift

    publicfuncdirection(_value:Direction)->Flex

    Parameters

    value

    Default value is .column

  • Thewrap property controls whether the flex container is single-lined or multi-lined, and the direction of the cross-axis, which determines the direction in which the new lines are stacked in.

    Declaration

    Swift

    publicfuncwrap(_value:Wrap)->Flex

    Parameters

    value

    Default value is .noWrap

  • Direction defaults to Inherit on all nodes except the root which defaults to LTR. It is up to you to detect the user’s preferred direction (most platforms have a standard way of doing this) and setting this direction on the root of your layout tree.

    Declaration

    Swift

    publicfunclayoutDirection(_value:LayoutDirection)->Flex

    Parameters

    value

    new LayoutDirection

    Return Value

justity, alignment, position

  • ThejustifyContent property defines the alignment along the main-axis of the current line of the flex container. It helps distribute extra free space leftover when either all the flex items on a line have reached their maximum size. For example, if children are flowing vertically,justifyContent controls how they align vertically.

    Declaration

    Swift

    publicfuncjustifyContent(_value:JustifyContent)->Flex

    Parameters

    value

    Default value is .start

  • ThealignItems property defines how flex items are laid out along the cross axis on the current line.Similar tojustifyContent but for the cross-axis (perpendicular to the main-axis). For example, ifchildren are flowing vertically,alignItems controls how they align horizontally.

    Declaration

    Swift

    publicfuncalignItems(_value:AlignItems)->Flex

    Parameters

    value

    Default value is .stretch

  • ThealignSelf property controls how a child aligns in the cross direction, overriding thealignItemsof the parent. For example, if children are flowing vertically,alignSelf will control how the flex item will align horizontally.

    Declaration

    Swift

    publicfuncalignSelf(_value:AlignSelf)->Flex

    Parameters

    value

    Default value is .auto

  • The align-content property aligns a flex container’s lines within the flex container when there is extra spacein the cross-axis, similar to how justifyContent aligns individual items within the main-axis.

    Declaration

    Swift

    publicfuncalignContent(_value:AlignContent)->Flex

    Parameters

    value

    Default value is .start

grow / shrink / basis

  • Thegrow property defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion. It dictates what amount of the available space inside the flex container the item should take up.

    Declaration

    Swift

    publicfuncgrow(_value:CGFloat)->Flex

    Parameters

    value

    Default value is 0

  • It specifies theflex shrink factor, which determines how much the flex item will shrink relative to the rest of the flex items in the flex container when there isn’t enough space on the main-axis.

    When omitted, it is set to 0 and the flex shrink factor is multiplied by the flexbasis when distributing negative space.

    A shrink value of 0 keeps the view’s size in the main-axis direction. Note that this may cause the view to overflow its flex container.

    Declaration

    Swift

    publicfuncshrink(_value:CGFloat)->Flex

    Parameters

    value

    Default value is 1

  • This property takes the same values as the width and height properties, and specifies the initial size of theflex item, before free space is distributed according to the grow and shrink factors.

    Specifyingnil set the basis asauto, which means the length is equal to the length of the item. If the item has no length specified, the length will be according to its content.

    Declaration

    Swift

    publicfuncbasis(_value:CGFloat?)->Flex

    Parameters

    value

    Default value is 0

Width / height / height

  • The value specifies the view’s width in pixels. The value must be non-negative.

    Declaration

    Swift

    publicfuncwidth(_value:CGFloat?)->Flex
  • The value specifies the view’s width in percentage of its container width. The value must be non-negative.Example: view.flex.width(20%)

    Declaration

    Swift

    publicfuncwidth(_percent:FPercent)->Flex
  • The value specifies the view’s height in pixels. The value must be non-negative.

    Declaration

    Swift

    publicfuncheight(_value:CGFloat?)->Flex
  • The value specifies the view’s height in percentage of its container height. The value must be non-negative.Example: view.flex.height(40%)

    Declaration

    Swift

    publicfuncheight(_percent:FPercent)->Flex
  • The value specifies view’s width and the height in pixels. Values must be non-negative.

    Declaration

    Swift

    publicfuncsize(_size:CGSize?)->Flex
  • The value specifies the width and the height of the view in pixels, creating a square view. Values must be non-negative.

    Declaration

    Swift

    publicfuncsize(_sideLength:CGFloat)->Flex
  • The value specifies the view’s minimum width in pixels. The value must be non-negative.

    Declaration

    Swift

    publicfuncminWidth(_value:CGFloat?)->Flex
  • The value specifies the view’s minimum width in percentage of its container width. The value must be non-negative.

    Declaration

    Swift

    publicfuncminWidth(_percent:FPercent)->Flex
  • The value specifies the view’s maximum width in pixels. The value must be non-negative.

    Declaration

    Swift

    publicfuncmaxWidth(_value:CGFloat?)->Flex
  • The value specifies the view’s maximum width in percentage of its container width. The value must be non-negative.

    Declaration

    Swift

    publicfuncmaxWidth(_percent:FPercent)->Flex
  • The value specifies the view’s minimum height in pixels. The value must be non-negative.

    Declaration

    Swift

    publicfuncminHeight(_value:CGFloat?)->Flex
  • The value specifies the view’s minimum height in percentage of its container height. The value must be non-negative.

    Declaration

    Swift

    publicfuncminHeight(_percent:FPercent)->Flex
  • The value specifies the view’s maximum height in pixels. The value must be non-negative.

    Declaration

    Swift

    publicfuncmaxHeight(_value:CGFloat?)->Flex
  • The value specifies the view’s maximum height in percentage of its container height. The value must be non-negative.

    Declaration

    Swift

    publicfuncmaxHeight(_percent:FPercent)->Flex
  • AspectRatio is a property introduced by Yoga that don’t exist in CSS. AspectRatio solves the problem of knowing one dimension of an element and an aspect ratio, this is very common when it comes to images, videos, and othermedia types. AspectRatio accepts any floating point value > 0, the default is undefined.

    Declaration

    Swift

    publicfuncaspectRatio(_value:CGFloat?)->Flex

    Parameters

    value

    Return Value

  • AspectRatio is a property introduced by Yoga that don’t exist in CSS. AspectRatio solves the problem of knowingone dimension of an element and an aspect ratio, this is very common when it comes to images, videos, and othermedia types. AspectRatio accepts any floating point value > 0, the default is undefined.

    Declaration

    Swift

    publicfuncaspectRatio(ofimageView:UIImageView)->Flex

    Parameters

    value

    Return Value

Absolute positionning

  • The position property tells Flexbox how you want your item to be positioned within its parent.

    Declaration

    Swift

    publicfuncposition(_value:Position)->Flex

    Parameters

    value

    Default value is .relative

  • Set the left edge distance from the container left edge in pixels.

    Declaration

    Swift

    publicfuncleft(_value:CGFloat)->Flex
  • Set the top edge distance from the container top edge in pixels.

    Declaration

    Swift

    publicfunctop(_value:CGFloat)->Flex
  • Set the right edge distance from the container right edge in pixels.

    Declaration

    Swift

    publicfuncright(_value:CGFloat)->Flex
  • Set the bottom edge distance from the container bottom edge in pixels.

    Declaration

    Swift

    publicfuncbottom(_value:CGFloat)->Flex
  • Set the start edge (LTR=left, RTL=right) distance from the container start edge in pixels.

    Declaration

    Swift

    publicfuncstart(_value:CGFloat)->Flex
  • Set the end edge (LTR=right, RTL=left) distance from the container start edge in pixels.

    Declaration

    Swift

    publicfuncend(_value:CGFloat)->Flex

Margins

  • Set the top margin. Top margin specify the offset the top edge of the item should have from from it’s closest sibling (item) or parent (container).

    Declaration

    Swift

    publicfuncmarginTop(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginTop(_percent:FPercent)->Flex
  • Set the left margin. Left margin specify the offset the left edge of the item should have from from it’s closest sibling (item) or parent (container).

    Declaration

    Swift

    publicfuncmarginLeft(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginLeft(_percent:FPercent)->Flex
  • Set the bottom margin. Bottom margin specify the offset the bottom edge of the item should have from from it’s closest sibling (item) or parent (container).

    Declaration

    Swift

    publicfuncmarginBottom(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginBottom(_percent:FPercent)->Flex
  • Set the right margin. Right margin specify the offset the right edge of the item should have from from it’s closest sibling (item) or parent (container).

    Declaration

    Swift

    publicfuncmarginRight(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginRight(_percent:FPercent)->Flex
  • Set the start margin.

    Depends on the itemLayoutDirection:

    • In LTR direction, start margin specify the offset theleft edge of the item should have from from it’s closest sibling (item) or parent (container).
    • IN RTL direction, start margin specify the offset theright edge of the item should have from from it’s closest sibling (item) or parent (container).

    Declaration

    Swift

    publicfuncmarginStart(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginStart(_percent:FPercent)->Flex
  • Set the end margin.

    Depends on the itemLayoutDirection:

    • In LTR direction, end margin specify the offset theright edge of the item should have from from it’s closest sibling (item) or parent (container).
    • IN RTL direction, end margin specify the offset theleft edge of the item should have from from it’s closest sibling (item) or parent (container).

    Declaration

    Swift

    publicfuncmarginEnd(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginEnd(_percent:FPercent)->Flex
  • Set the left, right, start and end margins to the specified value.

    Declaration

    Swift

    publicfuncmarginHorizontal(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginHorizontal(_percent:FPercent)->Flex
  • Set the top and bottom margins to the specified value.

    Declaration

    Swift

    publicfuncmarginVertical(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmarginVertical(_percent:FPercent)->Flex
  • Set all margins using UIEdgeInsets.This method is particularly useful to set all margins using iOS 11UIView.safeAreaInsets.

    Declaration

    Swift

    publicfuncmargin(_insets:UIEdgeInsets)->Flex
  • Set all margins to the specified value.

    Declaration

    Swift

    publicfuncmargin(_value:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmargin(_percent:FPercent)->Flex
  • Set the individually top, left, bottom and right margins.

    Declaration

    Swift

    publicfuncmargin(_top:CGFloat,_left:CGFloat,_bottom:CGFloat,_right:CGFloat)->Flex
  • Undocumented

    Declaration

    Swift

    publicfuncmargin(_top:FPercent,_left:FPercent,_bottom:FPercent,_right:FPercent)->Flex

Padding

  • Set the top padding. Top padding specify theoffset children should have from the container’s top edge.

    Declaration

    Swift

    publicfuncpaddingTop(_value:CGFloat)->Flex
  • Set the left padding. Left padding specify theoffset children should have from the container’s left edge.

    Declaration

    Swift

    publicfuncpaddingLeft(_value:CGFloat)->Flex
  • Set the bottom padding. Bottom padding specify theoffset children should have from the container’s bottom edge.

    Declaration

    Swift

    publicfuncpaddingBottom(_value:CGFloat)->Flex
  • Set the top padding. Top padding specify theoffset children should have from the container’s top edge.

    Declaration

    Swift

    publicfuncpaddingRight(_value:CGFloat)->Flex
  • Set the start padding.

    Depends on the itemLayoutDirection:

    • In LTR direction, start padding specify theoffset children should have from the container’s left edge.
    • IN RTL direction, start padding specify theoffset children should have from the container’s right edge.

    Declaration

    Swift

    publicfuncpaddingStart(_value:CGFloat)->Flex
  • Set the end padding.

    Depends on the itemLayoutDirection:

    • In LTR direction, end padding specify theoffset children should have from the container’s right edge.
    • IN RTL direction, end padding specify theoffset children should have from the container’s left edge.

    Declaration

    Swift

    publicfuncpaddingEnd(_value:CGFloat)->Flex
  • Set the left, right, start and end paddings to the specified value.

    Declaration

    Swift

    publicfuncpaddingHorizontal(_value:CGFloat)->Flex
  • Set the top and bottom paddings to the specified value.

    Declaration

    Swift

    publicfuncpaddingVertical(_value:CGFloat)->Flex
  • Set paddings using UIEdgeInsets.This method is particularly useful to set all paddings using iOS 11UIView.safeAreaInsets.

    Declaration

    Swift

    publicfuncpadding(_insets:UIEdgeInsets)->Flex
  • Set all paddings to the specified value.

    Declaration

    Swift

    publicfuncpadding(_value:CGFloat)->Flex
  • Set the individually top, left, bottom and right paddings.

    Declaration

    Swift

    publicfuncpadding(_top:CGFloat,_left:CGFloat,_bottom:CGFloat,_right:CGFloat)->Flex

UIView Visual properties

  • Set the view background color.

    Declaration

    Swift

    publicfuncbackgroundColor(_color:UIColor)->Flex

    Parameters

    color

    new color

    Return Value

    flex interface

Enums

© 2017lucdion. All rights reserved. (Last updated: 2017-12-10)

Generated byjazzy ♪♫ v0.9.0, aRealm project.


[8]ページ先頭

©2009-2025 Movatter.jp