ios - 撰写电子邮件时设置 UINavigationBar 标题颜色

标签 ios xamarin uiviewcontroller xamarin.ios

我有一个包含 WebView 的 ViewController。当我点击 WebView 中的电子邮件链接 (mailto:) 时,iOS 将推送一个允许用户撰写电子邮件的 ViewController。该 Controller 导航栏中的标题有黑色文本,我找不到更改颜色的方法。我能够更改导航栏的背景颜色以及按钮文本颜色,但不能更改标题颜色。

我正在使用 Xamarin (C#) 编写此应用程序,但如果作为解决方案提供,我应该能够翻译 Swift/Objective C 代码。

在我的应用程序委托(delegate)中,我设置了一些主题默认值。

UINavigationBar.Appearance.BarStyle = UIBarStyle.Black;
UINavigationBar.Appearance.BarTintColor = UIColor.Red;
UINavigationBar.Appearance.Translucent = false;
UINavigationBar.Appearance.TintColor = UIColor.White;
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
{
    TextColor = UIColor.White           
});

UINavigationBar.Appearance.TitleTextAttributes.ForegroundColor = UIColor.White;
UIButton.AppearanceWhenContainedIn(typeof(UINavigationBar)).TintColor = UIColor.White;

我还在每个 ViewController 中设置了 this.NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;。我假设这就是问题所在。我无法在撰写电子邮件 View Controller 中设置 BarStyle,并且它似乎没有使用全局外观值。

最佳答案

Xamarin.IOS 中:

如果想改变导航栏文字颜色,编码如下:

UIStringAttributes uIStringAttributes = new UIStringAttributes();
uIStringAttributes.ForegroundColor = UIColor.YouWantColor; //such as UIColor.Green
NavigationController.NavigationBar.TitleTextAttributes = uIStringAttributes;

enter image description here

如果想改变导航栏和状态栏,编码如下:

NavigationController.NavigationBar.BarTintColor = UIColor.YouWantColor;
// Color you want, such as UIColor.Green

enter image description here

关于ios - 撰写电子邮件时设置 UINavigationBar 标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56777613/

相关文章:

objective-c - 检查 URL 是否为本地文件?

c++ - 如何在 Objective-C 中包装一个巨大的静态 C++ 库?

ios - swift 2 如何单击数组中的特定图像以移至已存在的另一个页面

ios - 空结果集的 NSExpressionDescription

ios - 使用 XCode (Swift) 为学校和标签属性开发 iOS 应用程序不会刷新

android - 当 Toggled 和 disabled android switch 全部变灰时

objective-c - 使用 CGRectZero 初始化 UIView 的框架

iphone - 如果不在 iphone 应用程序中向下滚动,Scrollview 不会显示其内容的顶部

iphone - 制作一个应用程序引擎以用于类似的应用程序,但用于不同的客户端

c# - 使用读取和写入流保存文件时图像损坏