如果我有这样的代码:
self.view.addSubview(SomeImage1)
self.view.addSubview(SomeImage2)
self.view.addSubview(SomeImage3)
我如何切换 View 位置,我知道第一个 View 在索引 0,第二个在索引 1,所以有没有办法手动设置 View 索引,我是管理 View 的新手,还没有找到任何教程足以解决我的问题。
请您参考如下方法:
有一套完整的 UIView 方法可以解决这个问题:
func bringSubviewToFront(_ view: UIView)
func sendSubviewToBack(_ view: UIView)
func removeFromSuperview()
func insertSubview(_ view: UIView, atIndex index: Int)
func insertSubview(_ view: UIView, aboveSubview siblingSubview: UIView)
func insertSubview(_ view: UIView, belowSubview siblingSubview: UIView)
func exchangeSubviewAtIndex(_ index1: Int, withSubviewAtIndex index2: Int)
...等等。
您不应该使用数组索引来移动 View 。
