The beginning of the nonsense: simply create a keyboard extension class available for use by the system, it is the hand of the code world, useless world.

First, to achieve the effect display

Since the third-party keyboard is added in the phone Settings, you can use a custom keyboard in wechat, isn’t it interesting?

Second, create a project

1: Create a new project first

2: Click CreateTarget

Select a custom keyboard

After completion, the project will have more folders as shown in the figure.

Three, code implementation

KeyboardViewController file

1:KeyboardViewController.h

KeyboardViewController inherits from UIInputViewController in iOS

2:KeyboardViewController.m
Step 1: DeclarationWishView

It is the carrier of the surrounding wall and records the current azimuth Angle range, whether it has been used and the content

MinAngle: the minimum azimuth range Angle

MaxAngle: indicates the maximum azimuth range Angle

The rotation Angle of the center “tank” is judged between the maximum and minimum Angle to be the current brick

Step 2 createnextKeyboardButtonButton to ensure that the keyboard can be switched

You must switch keyboard input methods; otherwise, other input methods may be affected.

Step 3. Draw a picture: “ME” surrounded by bricks

Start by declaring some properties

Draw the tanks that are surrounded

The effect

Handle tank tap event, rotate random interval Angle

Handling fire incidents

Explosion effect

Circled in red is the text content to the current as the first responder input box!

Fourth, summary and thinking

After the app runs successfully, you need to add the current custom keyboard to the phone Settings to use it.

Don’t laugh at bad code.