1

So I have vc A & vc B. When I perform a push segue from A to B automatically creates a back button. This is great but I want to change the text color of this button to black with SetTitleTextAttributes.

From reading other questions relating to this I learned that you have to edit the back button that will appear in vc B in vc A. Somthing like this:

On vc A:

this.NavigationController.NavigationItem.BackBarButtonItem.SetTitleTextAttributes (textAttrButton, UIControlState.Normal);

On some questions they say to put this in the viewWillAppear others say just before you perform a segue to vc B. In both instances I get the following error:

object reference not set to an instance of an object

This is on vc B:

enter image description here

4

2 回答 2

1

更好的选择是为此使用 use UIAppearance。适用UIBarButtonItems于整个应用程序中的所有人,但需要 iOS。

UIBarButtonItem.Appearance.SetTitleTextAttributes(new TextAttributes { TextColor = UIColor.Black }, UIControlState.Normal);

于 2013-07-05T15:40:35.050 回答
0

您可以尝试使用导航栏后退按钮项的外观代理来更改属性。我不确定它是否或如何在 C# 中工作。

于 2013-07-07T21:28:40.160 回答