Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 2.10 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. set the alignment of title of navigation bar
  2. -(void)viewDidLoad {
  3.     UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStylePlain target:self action:@selector(goToHomePage:)];
  4.     [self.navigationController.navigationItem.rightBarButtonItem setTarget:self];
  5.     self.navigationItem.rightBarButtonItem = addButton;
  6.     [addButton release];
  7. }
  8.        
  9. [self.navigationItem setTitle:offertitle];
  10.        
  11. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 120, 40)];
  12. label.backgroundColor = [UIColor clearColor];
  13. label.font = [UIFont boldSystemFontOfSize:14.0];
  14. label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
  15. label.textAlignment = UITextAlignmentLeft;
  16. label.textColor =[UIColor whiteColor];
  17. label.text=offertit;
  18. self.navigationItem.titleView = label;
  19.        
  20. [self.navigationItem setTitle:@"Your Title"];
  21.        
  22. [self setTitle:@"Your Title"];
  23.        
  24. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  25. {
  26.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  27.     if (self)
  28.     {
  29.         // this will appear as the title in the navigation bar
  30.         UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
  31.         label.backgroundColor = [UIColor clearColor];
  32.         label.font = [UIFont boldSystemFontOfSize:20.0];
  33.         label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
  34.         label.textAlignment = UITextAlignmentCenter;
  35.         label.textColor = [UIColor yellowColor]; // change this color
  36.         self.navigationItem.titleView = label;
  37.         label.text = NSLocalizedString(@"PageThreeTitle", @"");
  38.         [label sizeToFit];
  39.     }
  40.  
  41.     return self;
  42. }
  43.        
  44. - (void)prepareNavigationTitle
  45. {
  46.     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(-50, 0.0, 240.0, 40.0)];
  47.     label.backgroundColor = [UIColor clearColor];
  48.     label.font = [UIFont boldSystemFontOfSize:14.0];
  49.     label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
  50.     label.textAlignment = UITextAlignmentLeft;
  51.     label.textColor =[UIColor whiteColor];
  52.     label.text=offertit;
  53.     self.navigationItem.titleView = label;
  54. }