How do I change the z index or stack order of UIView?

I would recommend looking in the UIView documentation, where are several methods listed for the manipulation of the order of subviews:

bringSubviewToFront(_:)
sendSubviewToBack(_:)
removeFromSuperview()
insertSubview(_:atIndex:)
insertSubview(_:aboveSubview:)
insertSubview(_:belowSubview:)
exchangeSubviewAtIndex(_:withSubviewAtIndex:)

In your situation, you could try:

self.view.sendSubviewToBack(myGradientView)
// self is your view controller in this case.

Alternatively, because you created the myGradientView in IB, you could change the view hierarchy to change which views appeared on top. Here’s a picture to illustrate:

enter image description here

Hope that helps.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)