本文介绍了从iOS7中的UIActivityViewController呈现时,无法在邮件编辑器中设置“发送”和“取消”按钮的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIActivityViewController在iOS7中共享项目。当我点击邮件选项时,它会弹出邮件编辑器,但导航栏上的取消和发送按钮以及导航栏本身都是蓝色,这使得它很难阅读,所以我想改变它们的颜色。它适用于iOS6但不适用于iOS7。

I am using the UIActivityViewController to share items in iOS7. When I tap on the Mail option, it pops up the mail composer, but the Cancel and Send buttons on the navigation bar and the navigation bar itself are blue, making it very difficult to read, so I want to change their color. It's working in iOS6 but not in iOS7.

我试过

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, nil] forState:UIControlStateNormal];

适用于iOS6,我试过

which works in iOS6, and I tried

[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];

这会导致颜色在第一次运行应用程序时闪烁红色,然后立即切换回蓝色颜色。

which causes the color to flash red the first time the app is run before immediately switching back to the blue color.

推荐答案

管理以更改发送取消的文字颜色按钮,位于 UMavailBos 中的 MFMailComposerViewController (两者发送取消)和 MFMessageComposeViewController (仅取消),当从 UIActivityViewController

Managed to change the text color of the Send and Cancel buttons, which are on the UINavigationBar in the MFMailComposerViewController (both Send and Cancel) and MFMessageComposeViewController (only Cancel), when presented from UIActivityViewController.

使用UIActivityViewController,点击消息 Mail

Using an UIActivityViewController, tap on Messageor Mail:

您会注意到发送取消按钮的默认文字颜色为蓝色:

You'll notice that the default text color of the Send and Cancel buttons is blue:

为了更改它,在 AppDelegate.m 类中,在 didFinishLaunchingWithOptions 方法中,插入以下行:

In order to change that, in the AppDelegate.m class, in the didFinishLaunchingWithOptions method, insert the following line:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];

这导致:

您还可以使用其他颜色,例如:

You can also use other colors, for example:

[UIColor purpleColor];

[UIColor greenColor];

我是如何测试的?我注意到这个解决方案适用于以下内容:


  • 使用Xcode 5.1,在iOS 7.1模拟器中构建为基础iOS SDK 7.1(可以从选择项目文件 - >构建设置 - >基础SDK。还可以选择一般 - >部署目标 - > 7.1)

  • 使用Xcode 5.1,在iPhone上4,构建为基础iOS SDK 7.0(可以从选择项目文件 - >构建设置 - >基础SDK中选择。另外,从常规 - >部署目标 - > 7.0中选择)

  • 使用Xcode 5.1,在iPhone 4上构建基本iOS SDK 7.1(可以从选择项目文件 - >构建设置 - >基础SDK中选择。另外,从常规 - >部署目标 - > 7.1中选择)

使用以下测试时无效:


  • 使用Xcode 5.1,在iOS 7.0模拟器中构建为基础iOS SDK 7.0(可以从选择项目文件 - > Build Settings - > Base SDK中选择。另外,从Genera中选择l - >部署目标 - > 7.0)

因此它应该是安全的,因为我相信实际设备上的行为很重要不仅仅是iOS模拟器中的行为。
如果有人知道为什么它在iOS 7.0模拟器中不起作用,我想知道。 :)

Therefore it should be safe to use, as I believe the behavior on the actual device matters more than the behavior in the iOS simulator. If anyone knows why it doesn't work in the iOS 7.0 simulator, I would like to know. :)

这篇关于从iOS7中的UIActivityViewController呈现时,无法在邮件编辑器中设置“发送”和“取消”按钮的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 09:30