views:

18

answers:

1

I am wanting to set the alpha of the titleView in my UINavigationController. Here is the code for this class:

#import "FAQNavigationController.h"


@implementation FAQNavigationController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {

    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

 self.navigationItem.titleView.alpha = 0.5;


    [super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end

Also, here is a screenshot of that result: As you can see the alpha hasn't changed.

alt text

Any ideas? Am I placing this in the wrong place?

+1  A: 

The problem is that self.navigationItem.titleView does not give you anything. The property can be set by you to replace the default label shown in your screen shot. However, there is no API designed to do what you want.

The question is: what do you want to achieve? You can make the bar translucent if you want to, or change it's tint. Changing the text opacity is not too easy. You could fiddle with the subviews of the controller's UINavigationBar, but I'd refrain from that.

Max Seelemann
Thanks for your answer, I'm actually needing to change the opacity of the actual title label. Do you have any idea on how I can accomplish this? I am trying to make a designer happy :)
Jesse Bunch
Don't make him happy, tell him that it's too hard. I posted a more detailled discussion and a possible solution in your other question here: http://stackoverflow.com/questions/3610826/subclassing-uinavigationbar-in-xcode
Max Seelemann