更改 MFMailComposeViewController 的工具栏颜色

发布于 2024-08-09 07:25:43 字数 604 浏览 9 评论 0原文

我在 iPhone 应用程序中使用有色导航栏和有色全局 UIToolbar。 在我的信息视图中,我有一个打开 MFMailComposeViewController 的按钮,并且该视图顶部的工具栏(带有“取消”和“发送”按钮)仍然是蓝色的。我这样调用 MFMailComposeViewController:

-(void)displayMailSheet
{

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"..."];

    NSArray *toRecipients = [NSArray arrayWithObject:@"..."]; 

    [picker setToRecipients:toRecipients];

    [self presentModalViewController:picker animated:YES];
    [picker release];

}

是否可以更改该视图工具栏的颜色?如果可能的话,我该怎么做?

I'm using a tinted navigation bar and a tinted global UIToolbar in my iPhone app.
In my info view, I have a button which opens a MFMailComposeViewController, and the toolbar at the top of that view (with the "cancel" and "send" button) is still blue. I'm calling the MFMailComposeViewController like this:

-(void)displayMailSheet
{

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"..."];

    NSArray *toRecipients = [NSArray arrayWithObject:@"..."]; 

    [picker setToRecipients:toRecipients];

    [self presentModalViewController:picker animated:YES];
    [picker release];

}

Is it possible to change the color of that view's toolbar? If it is possible, how can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

心意如水 2024-08-16 07:25:43

给你:

[[picker navigationBar] setTintColor:[UIColor blackColor]];

适用于 iOS 8.0

 [[picker navigationBar] setBarTintColor:[UIColor blackColor]];

Here you go:

[[picker navigationBar] setTintColor:[UIColor blackColor]];

for iOS 8.0

 [[picker navigationBar] setBarTintColor:[UIColor blackColor]];
时间你老了 2024-08-16 07:25:43

关于 iOS7 下此功能的一个小问题 - 色调颜色属性不再影响整个栏的颜色,而是仅更改“发送”和“取消”按钮的颜色(在 iOS7 风格中,这些按钮只是有色标签)。

如果您将标题栏颜色更改为白色或透明之类的颜色,则值得注意,因为在 iOS7 下,发送和取消按钮将不再可见。

A minor point about this functionality under iOS7 - the tint color property no longer affects the colour of the bar as a whole, instead it simply changes the colour of the 'Send' and 'Cancel' buttons (which, in iOS7 style, are simply tinted labels).

This is worth noting if you have changed the title bar colour to something like white or clear, as under iOS7 the send and cancel buttons will no longer be visible.

悍妇囚夫 2024-08-16 07:25:43

您可以从 appdelegate 全局执行此操作

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationbar-background.png"] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault]; // MFMailComposeViewController's navigationBar backgroundcolor 

NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], UITextAttributeTextColor, [UIColor whiteColor], UITextAttributeTextShadowColor, nil];
[[UINavigationBar appearance] setTitleTextAttributes:textTitleOptions];//MFMailComposeViewController's navigationBar text color 

you can do it globally from appdelegate

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationbar-background.png"] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault]; // MFMailComposeViewController's navigationBar backgroundcolor 

NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], UITextAttributeTextColor, [UIColor whiteColor], UITextAttributeTextShadowColor, nil];
[[UINavigationBar appearance] setTitleTextAttributes:textTitleOptions];//MFMailComposeViewController's navigationBar text color 
舟遥客 2024-08-16 07:25:43

只是想强调一下,上面关于苹果拒绝你的申请的帖子是一篇旧帖子。这是当前 MFMailComposeViewController 文档的引用...

重要:此类的视图层次结构是私有的,您不得修改它。但是,您可以自定义外观
使用 UIAppearance 协议实例。

Just want to emphasize that the above post about Apple rejecting your application is an old post. Here is a quote from the current MFMailComposeViewController documentation...

Important: The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an
instance by using the UIAppearance protocol.

一抹微笑 2024-08-16 07:25:43

试试这个:

MFMailComposeViewController *mailController  = [MFMailComposeViewController new];

[mailController.navigationBar setTintColor:[UIColor colorWithHue:240.0f/359.0f
                                                      saturation:85.0f/100.0f 
                                                      brightness:60.0f/100.0f 
                                                           alpha:0.0f]];

Try this:

MFMailComposeViewController *mailController  = [MFMailComposeViewController new];

[mailController.navigationBar setTintColor:[UIColor colorWithHue:240.0f/359.0f
                                                      saturation:85.0f/100.0f 
                                                      brightness:60.0f/100.0f 
                                                           alpha:0.0f]];
打小就很酷 2024-08-16 07:25:43

来自官方 MFMailComposeViewController 类参考:

重要提示:邮件撰写界面本身不可自定义,并且您的应用程序不得对其进行修改。 [...]

我认为在不进行任何更改的情况下呈现默认的邮件撰写界面将是一个更好的选择。否则 Apple 可能会拒绝您的申请。

在这里问问有没有人有过这样的经历。

From the official MFMailComposeViewController Class reference:

Important: The mail composition interface itself is not customizable and must not be modified by your application. [...]

I think it would be a better choice presenting the default mail composition interface without any changes. Otherwise Apple may reject your application.

Let's ask here if someone had an experience in this way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文