8

How to use UIKeyboardAppearanceDark with SLComposeViewController?


The SLComposeViewController class presents a view to the user to compose a post for supported social networking services.

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

[self presentViewController:controller
                   animated:YES
                 completion:nil];

SLComposeViewController Class Reference


Ugly!

This is how the light keyboard looks with a dark background:Ugly


Mockup!

This is how the dark keyboard looks with a dark background:Mockup

Zelko
  • 3,793
  • 3
  • 34
  • 40
  • 2
    This is a rare example currently in iOS of XPC. Due to this, there isn't really much you can do about it. Setting any type of UIApperance attributes only affect views in your app, but views gotten through XPC seemingly aren't effective. It is speculated that iOS 8 might open up some of this functionality to us developers so it might be worth it to just go with light keyboard for now and wait it out! It shouldn't hurt too much :) – Jack May 24 '14 at 03:48

4 Answers4

6

I have tried a few methods. The only way that I found working is to customize the entire ComposeViewController. I also believe it is the only possible way.

I found an open source project calls REComposeViewController and I customized it to have UIKeyboardAppearanceDark by default. I have uploaded to Github you can download and play with it.

Project: https://github.com/voyage11/SLComposeViewControllerWithBlackKeyboard

Attached Screen shot:-

enter image description here

Ricky
  • 10,485
  • 6
  • 36
  • 49
  • So this is completely custom? Does it still use the Social/Accounts framework? Does it work exactly the same as Apple's one? – Supertecnoboff Oct 06 '15 at 20:52
6

After carefully understanding the problem you are facing and doing some R&D, I'm suggest you to go for Custom ComposeViewController, because you can't change the keyboardAppearance of ComposeViewController's keyboard.

For implementing Customize ComposeViewController follow the below steps:

1) Made some custom view like SLComposeViewController's View.

2) On the post button you need to implement the logic in SLComposeViewControllerResultDone

 [_shareComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result)
 {

     switch (result)
     {
         case SLComposeViewControllerResultCancelled:

             break;
         case SLComposeViewControllerResultDone:
         {

         }
             break;
         default:
             break;
     }
 }];

3) And when you wants to show your custom view, make sure that the textView you are using in the custom view must be assign keyboardAppearance's property to UIKeyboardAppearanceDark

 self.yourTextField.keyboardAppearance = UIKeyboardAppearanceDark;

Below is the picture of customize view, that I implemented in a my recent project.

enter image description here

Hopefully it will helps you.

Irfan
  • 4,301
  • 6
  • 29
  • 46
1

This is a private class, thus your only chance is to traverse view hierarchy after SLComposeViewController has loaded its view, find corresponding UITextField and set keyboardAppearance to UIKeyboardAppearanceDark

Update scratch that, even traversing view hierarchy would be tricky (impossible) since it uses XPC and remote views.

Sash Zats
  • 5,376
  • 2
  • 28
  • 42
-2

You can use this code

self.yourTextField.keyboardAppearance = UIKeyboardAppearanceDark;