Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

set title to UINavigationBar

david_daviddavid_david Posts: 372Registered Users @ @
edited December 2009 in iPhone SDK Development
I start with window application, and I want to set a nav bar on my login page . I added one nav bar.
But when I add a title, the UILabel has white background, how can I make it transparent ?
or any other mehod to set title

navBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 20, cgRect.size.width, 40)];
	UILabel *lblTitle  = [[UILabel alloc]initWithFrame:CGRectMake(10,10,80,30)];
	lblTitle.text = @"Title";
	[navBar addSubview: lblTitle];
	[lblTitle release];
	[window addSubview:navBar];
Post edited by david_david on
<a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
The Lord's holy name be praised.
· ·

Replies

  • rajuraju Posts: 61Registered Users
    edited November 2008
    I start with window application, and I want to set a nav bar on my login page . I added one nav bar.
    But when I add a title, the UILabel has white background, how can I make it transparent ?
    or any other mehod to set title

    navBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 20, cgRect.size.width, 40)];
    	UILabel *lblTitle  = [[UILabel alloc]initWithFrame:CGRectMake(10,10,80,30)];
    	lblTitle.text = @"Title";
    	[navBar addSubview: lblTitle];
    	[lblTitle release];
    	[window addSubview:navBar];
    


    Hello David,

    set label's backgroundColor property to clearColor
    lblTitle.backgroundColor = [UIColor clearColor];

    Thanks,
    Raju
    · ·
  • david_daviddavid_david Posts: 372Registered Users @ @
    edited November 2008
    ohh....
    thank you very much
    <a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
    The Lord's holy name be praised.
    · ·
  • chbeerchbeer Posts: 229Registered Users
    edited November 2008
    For a navbar there is a navigationItem that has a title. This title is a simple NSString and is displayed correctly. Setting your own view as you did it is a more special case than setting a title. Please read the documentation!!!
    Learn vocabularies on iPhone? <a href="http://iphone.chbeer.de/iVocabulary" target="_blank">iVocabulary</a>!
    · ·
  • david_daviddavid_david Posts: 372Registered Users @ @
    edited November 2008
    chbeer wrote: »
    For a navbar there is a navigationItem that has a title. This title is a simple NSString and is displayed correctly. Setting your own view as you did it is a more special case than setting a title. Please read the documentation!!!

    hi, I didn't get you.. let me know how can I do it?

    /*I am doing that code in AppDelegate class, and creating my own UINavigationBar.*/
    <a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
    The Lord's holy name be praised.
    · ·
  • silviu_nanausilviu_nanau Posts: 3New Users
    edited November 2008
    UINavigationItem *navItem;
    navItem = [UINavigationItem alloc];
    navItem.titleView = lblTitle;
    [navBar pushNavigationItem:navItem animated:false];
    [navBar setDelegate:self];
    · ·
  • david_daviddavid_david Posts: 372Registered Users @ @
    edited November 2008
    thanks chbeer...
    thanks silviu...
    thanks to all...
    <a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
    The Lord's holy name be praised.
    · ·
  • chbeerchbeer Posts: 229Registered Users
    edited November 2008
    /*I am doing that code in AppDelegate class, and creating my own UINavigationBar.*/

    Why? Only for changing the title?

    Have a look at the documentation about UINavigationController and how to use it. Do you use Interface Builder?
    Learn vocabularies on iPhone? <a href="http://iphone.chbeer.de/iVocabulary" target="_blank">iVocabulary</a>!
    · ·
  • narendarnarendar Posts: 233
    edited April 2009
    Hey can we change the color of the naviagtionItem righbarbuttonitem????

    Actually I am changing the color of the navigation bar like this.
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

    Here rightbarbuttonitem color also changing to white.I want it to be in black.

    Thanks,
    Narendar
    · ·
  • unowenunowen Posts: 10Registered Users
    edited August 2009
    chbeer wrote: »
    For a navbar there is a navigationItem that has a title. This title is a simple NSString and is displayed correctly. Setting your own view as you did it is a more special case than setting a title. Please read the documentation!!!

    Is there a way to keep the text from overlapping the buttons if it's really long? Like a sizetofit action that UILabels have?
    · ·
  • Lukapple80Lukapple80 Posts: 65Registered Users
    edited December 2009
    Is it possible to change title of UINavigationBar if NavigationBar is created in Interface Builder (not generated dynamically) ?
    · ·
Sign In or Register to comment.