Drawing outside UIInputViewController frame

2019-04-08 19:05发布

问题:

Intro: I'm developing a keyboard extension for my native Armenian language.

The keyboard's features should look like maximum similar to system default keyboard.

One of the features I want to have inside my keyboard is to display Pop-ups on top of the touched buttons, like it is for English keyboard

As you can see the pop-up can be drawn outside the keyboard frame

Problem: I've managed to draw successfully the pop-up inside the frame of keyboard, but it gets masked to the keyboard frame, i.e. I'm not able to draw some part of pop-up outside of keyboard frame. I.e.

What I tried: I tried the to set the property view.layer.masksToBounds = NO; of UIInputViewController instance, but still I got my extension masked. The official docs are yet not quite descriptive on this issue. Although this might be one of the iOS keyboard extension limitations.

Any suggestions, references are welcomed on how to draw outside UIInputViewController frame ?

回答1:

The documentation says that this is not possible: In addition, it is not possible to display key artwork above the top row, as the system keyboard does on iPhone when you tap a key in the top row.



回答2:

What if you changed the height of the keyboard in the viewDidAppear() then the UIInputViewController will get expanded and you will be able to draw above the top row.

This trick used for adding a word prediction area but in your case I think its your only perfect solution ...

To expand it check Cris answer for Obj-C code or Satoshi's answer for swift code ... (Unable to change UIInputView height).

Good luck