UIStackView : Is it really necessary to call both removeFromSuperView and removeArrangedSubview to remove a subview?

后端 未结 8 778
遥遥无期
遥遥无期 2021-02-02 05:04

From the UIStackView Class Reference

In removeArrangedSubview:

To prevent the view from appearing on screen after calling the stack’s removeArrang

8条回答
  •  醉梦人生
    2021-02-02 05:26

    I will suggest get arranged subviews then remove it like below code .

    for view in self.stackView.arrangedSubviews{
          self.stackView.removeArrangedSubview(view)
          view.removeFromSuperview()
    }
    

提交回复
热议问题