Skip to content

If wrap(.wrap) is set, alignItems() doesn't work #278

@07akioni

Description

@07akioni

Without wrap:
Image

With wrap:
Image

Code:

import FlexLayout
import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        view.addSubview(MyView())
    }
}

class MyView: UIView {
    override init(frame: CGRect) {
        super.init(frame: .zero)

        flex.direction(.row).height(30).backgroundColor(.black).wrap(.wrap).alignItems(.center)
            .addItem().define { flex in
                flex.height(15)
                    .width(20)
                    .backgroundColor(.red)
            }
    }

    @available(*, unavailable)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func layout() {
        self.frame = .init(x: 0, y: 100, width: 200, height: 0)
        self.flex.layout(mode: .adjustHeight)
    }

    override func layoutSubviews() {
        self.layout()
    }
}

In CSS, flex wrap with align-items works properly:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions