I have created a navigation controller programmatically,
//Creating AddViewController Object
addViewController *addView = [[addViewController alloc]init];
UINavigationController *addViewControl = [[UINavigationController alloc]init];
[addViewControl.view addSubview:addView.view];
[self presentModalViewController:addViewControl animated:YES];
But when i add self.title = @"Title" in addViewController class. it is not displaying.
i tried with the following,
self.navigationItem.title = @"Title";
self.navigationController.navigationBar.topItem.title = @"Title";
But it's not displaying Title.
I think it is possible to do with setting a label. but the above one is direct method.
Any Idea..
Use navigationBarTitle(_:) to set the title of the navigation bar. This modifier only takes effect when this view is inside of and visible within a NavigationView .
To customize a navigation bar title view in SwiftUI, we simply set ToolbarItem of placement type . principal to a new . toolbar modifier.
Go to the ViewController. swift file and add the ViewDidAppear method. a nav helper variable which saves typing. the Navigation Bar Style is set to black and the tint color is set to yellow, this will change the bar button items to yellow.
You should assign the title to the addView
like addView.title = @"Title";
Another way to do it is self.navigationItem.title = @"Title";
In the viewController class:
[self setTitle:@"title"];
or self.title=@"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