Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

putting labels, buttons on the navigation bar iOS

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];
like image 307
erdemgc Avatar asked Jul 12 '13 08:07

erdemgc


People also ask

Can you change Iphone navigation bar?

Change the Bar StyleA user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.


1 Answers

UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 66)];

    UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(200,8,200,30)];
    navLabel.text = @"My Text";
    navLabel.textColor = [UIColor redColor];
    [naviBarObj addSubview:navLabel];
    [navLabel setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview:naviBarObj];

try this it will work .It works for me :)

like image 86
Kasaname Avatar answered Nov 13 '22 15:11

Kasaname