Gigi
Gigi

Reputation: 315

How to disable background when keyboard appears

I want to disable the application background when the UITextField keyboard appears. I would like to create the same effect of the Action Sheet. Is it possible? Thanks, Luigi.

Upvotes: 0

Views: 195

Answers (1)

rmaddy
rmaddy

Reputation: 318794

One option would be to add a clear (or tinted) view that covers the entire view controller's view. This would appear under the keyboard so you would still be able to type. But the view would prevent any touch interactions with the rest of the view controller (including the text field).

You could implement the UITextFieldDelegate method textFieldDidBeginEditing: so it adds the view and the textFieldDidEndEditing: method so it removes the view.

Of course you need to ensure that the keyboard input allows you to dismiss the keyboard, otherwise the view will never get removed.

BTW - why do you want to do this? It's very unusual.

Upvotes: 2

Related Questions