How do I programatically set my right navigation bar button's title. I've tried
[self.navigationItem.rightBarButtonItem setTitle:@"Test"];
and have also tried creating an outlet for the button and then trying to assign it a value.
self.rightBarButton.titleLabel.text = @"Test";
Try this:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Test" style:UIBarButtonItemStylePlain target:target action:action];
For Swift use this,
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Title", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("methodName"))
Set Color of Title using this,
self.navigationItem.rightBarButtonItem?.tintColor = UIColor.whiteColor()
Please try this, it works:
self.navigationItem.rightBarButtonItem.title = @"New Title";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With