Skip to content

Add convenient way for using layout margins guide #113

@thomasalbert1993

Description

@thomasalbert1993

Let say I want to pin my subview to parent's layout margin guide. I have to write:

let stackView = UIStackView(arrangedSubviews: buttons)
[...]
contentView.addSubview(stackView)
stackView.topToSuperview(contentView.layoutMarginsGuide.topAnchor)
stackView.leftToSuperview(contentView.layoutMarginsGuide.leftAnchor)
stackView.rightToSuperview(contentView.layoutMarginsGuide.rightAnchor)
stackView.bottomToSuperview(contentView.layoutMarginsGuide.bottomAnchor)

Which is not convenient. If I wanted to pin it to parent's safe guide, I would just write:

stackView.edgesToSuperview(usingSafeArea: true)

It would be amazing to be able to do the same for margin guide.
May be an enum like:

enum LayoutGuide {
    case safeArea
    case margins
}
[...]
stackView.edgesToSuperview(using: .margins)

🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions