下面代码可以遍历移除页面视图上的所有元件:
//清空所有子视图 func clearViews() { for v in self.view.subviews as [UIView] { v.removeFromSuperview() } }
下面代码可以遍历移除页面视图上的所有元件:
//清空所有子视图 func clearViews() { for v in self.view.subviews as [UIView] { v.removeFromSuperview() } }
转载于:https://www.cnblogs.com/hero11223/p/5754062.html