我有一个MFMailComposeViewController,当我设置了主题时,它也将它设置为主题。
问题是如何自定义标题和颜色的字体?

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[picker setSubject:@"Feedback for MyApp"];

最佳答案

我已从所有视图控制器的所有导航栏的app-delegate更改了我的应用程序的字体。如果您不介意更改所有导航栏标题字体,请在applicationDidFinishLaunching:withOptions:中输入以下内容

    if ([[UINavigationBar class] respondsToSelector:@selector(appearance)])
        // set the navigation bar font to "courier-new bold 14"
        [[UINavigationBar appearance] setTitleTextAttributes:
         [NSDictionary dictionaryWithObjectsAndKeys:[UIColor lightGrayColor], UITextAttributeTextShadowColor,
                                                    [NSValue valueWithUIOffset:UIOffsetMake(1, 0)], UITextAttributeTextShadowOffset,
                                                    [UIFont fontWithName:@"CourierNewPS-BoldMT" size:14.0], UITextAttributeFont,
                                                    nil]];

更新:
如果您希望特定于此情况,则可以使用exteriorWhenContainedIn:使用下面注释中建议的Alexander Akers参数,因为UIViewController继承自UIAppearanceContainer。我知道AppearanceWhenContainedIn:在其他情况下都可以使用,例如UINavigationBar中包含的UIBarButtonItems,因此在这种情况下应该可以类似地工作。

10-08 06:56
查看更多