Remove all the subviews from a UIScrollView?

前端 未结 5 1876
-上瘾入骨i
-上瘾入骨i 2021-02-02 06:08

How do I remove all of the subviews from a UIScrollview?

5条回答
  •  庸人自扰
    2021-02-02 06:56

    Complementing the Swift concise version from a previous answer (Swift 3.0 ready):

    _ = scrollView.subviews.filter { $0 is UIImageView }.map { $0.removeFromSuperview() }
    

提交回复
热议问题