不用循环,一行代码移除所有子视图
[view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
本文标题:ios 移除所有子视图
本文链接:https://www.haomeiwen.com/subject/zvznkttx.html
网友评论
//[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
while (self.subviews.count) {
[self.subviews.lastObject removeFromSuperview];
}
}
这个方法不错,YYKit 的源码
所以还是乖乖用回循环好点