简体   繁体   中英

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!

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM