Problem UICollectionViewController When Trying to Use bringSubview Swift 4
Hi guys, I found unique issue when trying to use bringSubview in UICollectionViewController. The method doesn't work if you try like this.
UICollectionViewController has a diffrent to do add subview. Because it's not pure UIViewController itself or parent. It needs to get superview to add a new view.
So basically you do like below and nothing happened or it doesn't work. Don't worry about it, i have a solution for you. It's simple way to do it and don't make you think too much. I find this idea on stackoverflow. I will put the link below.
So to do trick you need to use superview!.
reference : https://stackoverflow.com/questions/26850501/swift-bringsubviewtofront-not-working
UICollectionViewController has a diffrent to do add subview. Because it's not pure UIViewController itself or parent. It needs to get superview to add a new view.
So basically you do like below and nothing happened or it doesn't work. Don't worry about it, i have a solution for you. It's simple way to do it and don't make you think too much. I find this idea on stackoverflow. I will put the link below.
self.view!.addSubview(something) self.view!.bringSubview(toFront: something)
So to do trick you need to use superview!.
self.view!.superview!.addSubview(something) self.view!.superview!.bringSubview(toFront: something)
reference : https://stackoverflow.com/questions/26850501/swift-bringsubviewtofront-not-working