[英]for each not bringing subview to front ios swift
I've added the following extension to UIView
: 我向UIView
添加了以下扩展名:
func bringViewsToFront(views : [UIView]) {
views.forEach { (view) in
self.bringSubviewToFront(view)
}
which I use like this: 我这样使用:
imageOverlay.bringViewsToFront(views: [v1, v2, v3])
However this doesn't seem to work - whereas the traditional way below does: 但是,这似乎不起作用-而下面的传统方式可以:
imageOverlay.bringSubviewToFront(v1)
imageOverlay.bringSubviewToFront(v2)
imageOverlay.bringSubviewToFront(v3)
Any idea why? 知道为什么吗?
Well, I bet there is not problem with your for each. 好吧,我敢打赌,你们每个人都没有问题。 Just make sure that the views you're passing as parameter are direct subviews (not grandchildren subviews). 只需确保您要作为参数传递的视图是直接子视图(而不是孙子视图)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.