SLComposeViewController黑暗键盘外观

时间:2014-05-12 04:46:29

标签: ios ios7 uikeyboard ios7.1 uiappearance

如何将UIKeyboardAppearanceDarkSLComposeViewController一起使用?


SLComposeViewController课程向用户显示撰写支持的社交网络服务帖子的视图。

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

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

SLComposeViewController Class Reference


难看!

这是浅色键盘在深色背景下的外观:Ugly


样机!

这是黑暗键盘在深色背景下的外观:Mockup

4 个答案:

答案 0 :(得分:6)

我尝试过几种方法。我发现工作的唯一方法是自定义整个 ComposeViewController 。我也相信这是唯一可能的方式。

我发现一个开源项目调用 REComposeViewController ,我默认将其定制为 UIKeyboardAppearanceDark 。我已经上传到Github,你可以下载并玩它。

项目https://github.com/voyage11/SLComposeViewControllerWithBlackKeyboard

附加屏幕截图: -

enter image description here

答案 1 :(得分:6)

在仔细了解您所面临的问题并做一些R& D之后,我建议您选择自定义 ComposeViewController,因为您无法更改{{1 } keyboardAppearance键盘。

要实施自定义 ComposeViewController's,请按照以下步骤操作:

1)制作了一些自定义视图,例如ComposeViewController查看。

2)在发布按钮上,您需要在SLComposeViewController's

中实施逻辑
SLComposeViewControllerResultDone

3)当您想要展示自定义视图时,请确保您在自定义视图中使用的 textView 必须指定 [_shareComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) { switch (result) { case SLComposeViewControllerResultCancelled: break; case SLComposeViewControllerResultDone: { } break; default: break; } }]; 属性到keyboardAppearance's

UIKeyboardAppearanceDark

以下是我在最近的项目中实施的自定义视图的图片。

enter image description here

希望它能帮到你。

答案 2 :(得分:1)

这是一个私有类,因此您唯一的机会是在SLComposeViewController加载其视图后遍历视图层次结构,找到相应的UITextField并将keyboardAppearance设置为UIKeyboardAppearanceDark < / p>

更新暂时,即使遍历视图层次结构也很棘手(不可能),因为它使用XPC和远程视图。

答案 3 :(得分:-2)

您可以使用此代码

self.yourTextField.keyboardAppearance = UIKeyboardAppearanceDark;