我使用的是有色的导航栏,在我的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];
}
是否有可能改变这一观点的工具栏的颜色? 如果可能的话,我该怎么办呢?
干得好:
[[picker navigationBar] setTintColor:[UIColor blackColor]];
适用于iOS 8.0
[[picker navigationBar] setBarTintColor:[UIColor blackColor]];
关于iOS7下此功能一个小点 - 着色颜色属性不再影响酒吧作为一个整体的颜色,而不是简单地改变颜色“发送”和“取消”按钮(在iOS7风格,只是有色标签)。
如果您更改了标题栏颜色像白色或透明,为iOS7下发送和取消按钮将不再可见这是值得注意的。
你可以从全球的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
只是想强调的是,上述关于苹果拒绝你的申请后是一个老帖子。 下面是从当前MFMailComposeViewController文档报价...
重要提示 :本类的视图层次是私有的,你不能修改它。 你可以,但是,通过使用UIAppearance协议自定义实例的外观。
试试这个:
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]];
从MFMailComposeViewController类的官方参考:
重要提示:邮件撰写界面本身不是定制的,不得通过您的应用程序进行修改。 [...]
我认为这将是一个更好的选择呈现默认的邮件撰写界面无任何变化。 否则,苹果可能会拒绝你的申请。
让我们在这里问,如果有人有这样的经历。