更改MFMailComposeViewController的工具栏颜色
我在iPhone应用程序中使用有色导航栏和有色全局UIToolbar。 在我的信息视图中,我有一个打开MFMailComposeViewController的按钮,该视图顶部的工具栏(“取消”和“发送”按钮)仍然是蓝色的。我打电话给这样的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];
}
是否有可能改变该视图的工具栏的颜色?如果可能的话,我该怎么做?
在这里你去:
[[picker navigationBar] setTintColor:[UIColor blackColor]];
适用于iOS 8.0
[[picker navigationBar] setBarTintColor:[UIColor blackColor]];
从MFMailComposeViewController类的官方参考:
重要提示:邮件撰写界面本身不是定制的,绝不能由您的应用程序修改。 [...]
我认为这将是一个更好的选择,呈现默认的邮件编排界面,无需任何更改。否则,Apple可能会拒绝您的申请。
让我们来问问这里是否有人有这种经验。
Fat Booth尽力避开它。 – 2010-07-19 00:35:54
你可以从appdelegate全局做到这一点。 – 2013-11-19 15:35:11
试试这个:
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]];
约iOS7下此功能一个小点 - 着色颜色属性不再影响酒吧作为一个整体的颜色,而是它只是改变的“发送”颜色和'取消'按钮(这在iOS7风格中是简单的彩色标签)。
如果您已将标题栏颜色更改为白色或清晰等颜色,则值得注意,因为在iOS7下,发送和取消按钮将不再可见。
只是想强调一下,上述关于苹果拒绝你的应用程序的帖子是一个旧帖子。下面是从当前MFMailComposeViewController文档报价...
重要:这个类的视图层次是私有的,你不能修改它。但是,您可以使用UIAppearance协议自定义实例的外观。
你可以从的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
全球范围内做到这一点,你有没有尝试设置picker.navigationBar.tintColor? – 2009-10-28 00:03:19
这工作正常!谢谢! :-) – iYassin 2009-10-28 09:23:21