justa justa - 9 months ago 65
Swift Question

Insert subview above inputAccessoryView

My problem is this:
I have a UIViewController with an input accessory view:

class ChatViewController: UIViewController {
override var inputAccessoryView: UIView! {
get { return customToolbar }

I would like to be able to add a subview above that inputAccessoryView, something like this:

let customView = UIView()
customView.backgroundColor = UIColor.blueColor()
self.view.insertSubview(customView, aboveSubview: self.inputAccessoryView)

But for some reasons, the inputAccessoryView is always on top.

I have thought of hiding it each time i want to add a subview (full screen for instance), but this is not super clean, and I'd have to put it back each time i remove my subview.

Here's what I have right now, I just want my toolbar to be behind the transparent overlay.

enter image description here


Try to add your transparent overlay to keyWindow in the Objective-C it's look like

[[[UIApplication sharedApplication].windows lastObject] addSubview :customView];