- set the alignment of title of navigation bar
- -(void)viewDidLoad {
- UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStylePlain target:self action:@selector(goToHomePage:)];
- [self.navigationController.navigationItem.rightBarButtonItem setTarget:self];
- self.navigationItem.rightBarButtonItem = addButton;
- [addButton release];
- }
- [self.navigationItem setTitle:offertitle];
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 120, 40)];
- label.backgroundColor = [UIColor clearColor];
- label.font = [UIFont boldSystemFontOfSize:14.0];
- label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
- label.textAlignment = UITextAlignmentLeft;
- label.textColor =[UIColor whiteColor];
- label.text=offertit;
- self.navigationItem.titleView = label;
- [self.navigationItem setTitle:@"Your Title"];
- [self setTitle:@"Your Title"];
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self)
- {
- // this will appear as the title in the navigation bar
- UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
- label.backgroundColor = [UIColor clearColor];
- label.font = [UIFont boldSystemFontOfSize:20.0];
- label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
- label.textAlignment = UITextAlignmentCenter;
- label.textColor = [UIColor yellowColor]; // change this color
- self.navigationItem.titleView = label;
- label.text = NSLocalizedString(@"PageThreeTitle", @"");
- [label sizeToFit];
- }
- return self;
- }
- - (void)prepareNavigationTitle
- {
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(-50, 0.0, 240.0, 40.0)];
- label.backgroundColor = [UIColor clearColor];
- label.font = [UIFont boldSystemFontOfSize:14.0];
- label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
- label.textAlignment = UITextAlignmentLeft;
- label.textColor =[UIColor whiteColor];
- label.text=offertit;
- self.navigationItem.titleView = label;
- }