Parad0x13
Parad0x13

Reputation: 2065

MFMessageComposeViewController Semi-Transparent Keyboard

I'm trying to initiate a MFMessageComposeViewController with a semi transparent keyboard. I would like to make it as transparent as I want, but I don't think we are allowed to do that from the reading that I've done.

How would you set the property of the UIKeyboard when you create the MFMessageComposeViewController?

Many Thanks!

Upvotes: 1

Views: 404

Answers (2)

J2theC
J2theC

Reputation: 4452

You do not. From the documentation:

Important The message composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is unable to make further changes to the SMS content. The user can edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields, if desired, before presenting the interface.

You are not supposed to change this interface, since UIKeyboard is private and the textfields on this view are not accessible by you. Attempting to access and modify this textfield via the view hierarchy might get your app rejected in the app store.

Upvotes: 4

Noah
Noah

Reputation: 67

Setting the keyboardAppearance property of your text field or text view to UIKeyboardAppearanceAlert will change the keyboard to the transparent keyboard.

I heard that there's only two styles available in the public API:

[textView setKeyboardAppearance:UIKeyboardAppearanceAlert];
[textView setKeyboardAppearance:UIKeyboardAppearanceDefault];

But you can use private API methods to retrieve the keyboard implementation:

id keyboardImpl = [objc_getClass("UIKeyboardImpl") sharedInstance];

And Make it less opaque,

[keyboardImpl setAlpha:0.8f];

Tint it,

UIView *tint = [[UIView alloc] initWithFrame:[keyboardImpl frame]];
[tint setBackgroundColor:[UIColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:0.3f]];
[tint setUserInteractionEnabled:NO];
[[keyboardImpl superview] insertSubview:tint aboveSubview:keyboardImpl];
[tint release];

Or even flip it:

[[keyboardImpl window] setTransform:CGAffineTransformMakeScale(-1.0f, 1.0f)];

Hope it was the solution for your problem.

Upvotes: 1

Related Questions