sakiyamaK / DeclarativeUIKit

Library for writing UIKit Autolayout declaratively.
MIT License
75 stars 3 forks source link

UIStackView margins #140

Closed Omarbasaleh closed 3 months ago

Omarbasaleh commented 4 months ago

You may add support to directionalLayoutMargins of UIStackView. So we can use the build in support of margins instead of using extra views when we use padding().

extension UIStackView {
    @discardableResult
    func directionalLayoutMargins(_ margins: NSDirectionalEdgeInsets) -> Self {
        self.isLayoutMarginsRelativeArrangement = true
        self.directionalLayoutMargins = margins
        return self
    }
}
sakiyamaK commented 3 months ago

Thank you. I'll get right on with the modifications. The isLayoutMarginsRelativeArrangement is a UIStackView parameter, but the directionalLayoutMargins is a UIView parameter, so I'll extend it to each.

sakiyamaK commented 3 months ago

add some functions

extension UIStackView {
    @discardableResult
    func margins(_ margins: NSDirectionalEdgeInsets) -> Self {
        self.isLayoutMarginsRelativeArrangement(true).directionalLayoutMargins(margins)
    }
}
sakiyamaK commented 3 months ago

https://github.com/sakiyamaK/DeclarativeUIKit/releases/tag/3.2.0