What is the best way to remove all subviews from you self.view?

前端 未结 5 580
孤城傲影
孤城傲影 2020-12-12 12:07

I was thinking maybe something like this might work:

    for (UIView* b in self.view.subviews)
    {
       [b removeFromSuperview];
    }

5条回答
  •  孤城傲影
    2020-12-12 13:12

    self.view.subviews.forEach({ $0.removeFromSuperview() })
    

    Identical version in Swift.

提交回复
热议问题