Check out example codes for "how to change background color of stackview swift". It will help you in understanding the concepts better.

Code Example 1

extension UIStackView {
    func addBackground(color: UIColor) {
        let subView = UIView(frame: bounds)
        subView.backgroundColor = color
        subView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        insertSubview(subView, at: 0)
    }
}

Learn ReactJs, React Native from akashmittal.com