Overlapping Views in UIStackView

后端 未结 7 1679
时光说笑
时光说笑 2020-12-14 17:24

I have an horizontal stack view that I added arranged sub views to it (7 cells). Each one of the cells in the stack has a circular badge that exceeds the view boundaries (ne

相关标签:
7条回答
  • 2020-12-14 17:53

    This Swift solution reverses the stack view subview order using the UIView method sendSubviewToBack(_:) (docs here):

    @IBOutlet weak var stackView: UIStackView!
    
    for view in stackView.arrangedSubviews {
        stackView.sendSubviewToBack(view)
    }
    

    As we advance through the stack view's arranged views (from bottom to top), the later (i.e. higher) views get pushed to the bottom, thereby reversing the order :-)

    0 讨论(0)
提交回复
热议问题