[lib] FlexLayout란?

FlexLayout

사용해야하는 이유

FlexLayout의 특징

FlexLayout Performance

스크린샷 2021-05-14 오전 10 28 17

사용법

Creation, modification and definition of flexbox items

1. addItem(:UIView)

  view.flex.addItem(imageView).width(100).aspectRatio(1)

2. addItem()

  view.flex.addItem().direction(.row).padding(10)

3. define()

  view.flex.addItem().define { (flex) in
      flex.addItem(imageView).grow(1)
        
      flex.addItem().direction(.row).define { (flex) in
          flex.addItem(titleLabel).grow(1)
          flex.addItem(priceLabel)
      }
  }

The same results can also be obtained without using the define() method, but the result is not as elegant:

  let columnContainer = UIView()
  columnContainer.flex.addItem(imageView).grow(1)
  view.flex.addItem(columnContainer)
        
  let rowContainer = UIView()
  rowContainer.flex.direction(.row)
  rowContainer.flex.addItem(titleLabel).grow(1)
  rowContainer.flex.addItem(priceLabel)
  columnContainer.flex.addItem(rowContainer)

4. layout()

Layout modes:

rootFlexContainer.flex.layout(mode: .adjustHeight)

Flexbox containers properties

1. direction()

스크린샷 2021-05-14 오후 3 47 59

Example:

view.flex.direction(.column)  // Not required, default value. 
view.flex.direction(.row)

2. justifyContent()

스크린샷 2021-05-14 오후 3 49 50

Example:

view.flex.justifyContent(.start)  // default value. 
view.flex.justifyContent(.center)

3. alignItems()

스크린샷 2021-05-14 오후 3 51 26

4. alignSelf()

5. wrap()

스크린샷 2021-05-14 오후 3 53 12

Example:

view.flex.wrap(.nowrap)  // Not required, default value. 
view.flex.wrap(.wrap)

6. alignContent()

스크린샷 2021-05-14 오후 3 54 16

7. layoutDirection()

Using start or end properties, you can position views without having to think about whether your item will show up on the left or the right side of the screen (depending on the person’s language

Method:

FlexLayout git 주소

스크린샷 2021-05-14 오전 10 21 11

https://github.com/layoutBox/FlexLayout