Overlapping Views in UIStackView

后端 未结 7 1694
时光说笑
时光说笑 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:44

    I was looking to prevent overlapping all together. I tried the sendSubviewToBack method, but all that did was shift the overlap to the other side, unsurprisingly.

    In my case, this was caused by an image view on my subview being set to scaleToFill which meant some of the image was actually overlapping the next view. My solution to this was, in my subview class (the view that was going into the stack view), was to simply enable mask to bounds

    view.maskToBounds = true

    This means that it just crops out anything that is hanging outside.

提交回复
热议问题