Reactant icon indicating copy to clipboard operation
Reactant copied to clipboard

Add method for removing all views from a superview.

Open matoushybl opened this issue 6 years ago • 1 comments

This is quite useful when working with our stack and UIStackView.

extension UIView {
    @discardableResult
    public func removeSubviews() -> [UIView] {
        let subviews = self.subviews
        for subview in subviews {
            subview.removeFromSuperview()
        }

        return subviews
    }
}

matoushybl avatar Jul 13 '18 08:07 matoushybl

What use is returning the removed views?

MatyasKriz avatar Jul 13 '18 10:07 MatyasKriz