gpt4 book ai didi

c# - NavigationController 颜色和左键

转载 作者:行者123 更新时间:2023-11-28 22:22:14 25 4
gpt4 key购买 nike

我正在尝试制作我的第一个基于表格的应用程序。但是它不会改变导航栏上标题的颜色。

我试过这段代码,但它似乎不起作用:

this.NavigationController.NavigationItem.TitleView.TintColor = UIColor.White;

我还制作了一个 LeftBarButtonItem,但是我看不到它,但是当点击它应该在的地方时,它确实做了它应该做的事..

    this.NavigationController.NavigationItem.SetHidesBackButton (true, false);
this.NavigationController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem ();
this.NavigationController.NavigationItem.LeftBarButtonItem.Style = UIBarButtonItemStyle.Plain;
this.NavigationController.NavigationItem.LeftBarButtonItem.TintColor = UIColor.White;
this.NavigationController.NavigationItem.LeftBarButtonItem.Title = "Tilbage";
this.NavigationController.NavigationItem.LeftBarButtonItem.Clicked += (object sender, EventArgs e) =>
{
this.PerformSegue("fromItem", this);
};

最佳答案

要更改导航栏中标题的颜色,请查看 this answer .

对于导航栏中的自定义按钮,请查看 this answer

如果您在将 Objective-C 转换为 C# 时遇到任何问题,请发表评论。

编辑

ViewControllerViewDidLoad 中添加:

// to change the appearance of the top navigation bar title
UITextAttributes attributes = new UITextAttributes();
// set custom text color
attributes.TextColor = UIColor.FromRGB(255, 122, 122);
attributes.Font = UIFont.BoldSystemFontOfSize(20);
attributes.TextShadowColor = UIColor.FromRGBA(255, 255, 255, 128);
attributes.TextShadowOffset = new UIOffset(2, -2);

// to add buttons to navigation bar
UIBarButtonItem[] items = new UIBarButtonItem[]
{
new UIBarButtonItem(
NSBundle.MainBundle.LocalizedString("Tilbage", null),
UIBarButtonItemStyle.Bordered,
delegate(object sender, EventArgs e) {
// do whatever you need
Console.WriteLine("Custom button clicked!");
})
};

NavigationController.NavigationBar.TintColor = UIColor.FromRGBA(255, 196, 196, 255);
NavigationController.NavigationBar.TopItem.Title = NSBundle.MainBundle.LocalizedString("LocalizedHeader", null);
// change appearance
NavigationController.NavigationBar.SetTitleTextAttributes(attributes);
// add buttons
NavigationItem.LeftBarButtonItems = items;

关于c# - NavigationController 颜色和左键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20025013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com