I have created custom navigation controller,
I want to be added, a date at the left, a back button on the right and the title next to back button.
I tried to add one label, but it does not work. Please show me a way
UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 66)];
UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,8,280,30)];
navLabel.text = @"My Text";
[self.navigationController.navigationBar addSubview:navLabel];
[self.view addSubview:naviBarObj];
try this it will work .It works for me :)
You can also achieve this from
Interface Builder
1. First add a
UIView
which will look like following2. Then add a
UILabel
inside theUIView
which will look like following3. In the Center It will look like following
Now add necessary constraint to meet your requirement.
You need to change the
titleView
of thetopItem
. Like this:** update: Complete code (tested and working) **
add custom view in
UIToolbar
You need to add navigation item to the navigation bar. One per each navigation level. So you should have at least one of them.
** update **