iPhone navigatiebalk Titel tekstkleur

stemmen
272

Het lijkt erop dat de iOS navigatiebalk titel kleur is wit standaard. Is er een manier om het te veranderen naar een andere kleur?

Ik ben me bewust van de navigationItem.titleViewbenadering met behulp van een afbeelding. Sinds mijn ontwerp vaardigheden zijn beperkt en ik niet aan de norm glossy te krijgen, geef ik de voorkeur het veranderen van de tekstkleur.

Het even welk inzicht zou zeer gewaardeerd worden.

De vraag is gesteld op 01/03/2009 om 07:51
bron van user
In andere talen...                            


32 antwoorden

stemmen
410

moderne aanpak

De moderne manier, voor de gehele navigatie controller ... doe dit keer, wanneer uw navigatie controller root view wordt geladen.

[self.navigationController.navigationBar setTitleTextAttributes:
   @{NSForegroundColorAttributeName:[UIColor yellowColor]}];

Echter, dit lijkt niet een effect hebben in de daaropvolgende uitzicht.

Classic aanpak

De oude manier, per view controller (deze constanten zijn voor iOS 6, maar als het wilt doen per view controller op iOS 7 uiterlijk jij dezelfde aanpak, maar met verschillende constanten wilt):

Je moet een te gebruiken UILabelals titleViewvan de navigationItem.

Het label moet:

  • Heeft u een duidelijke achtergrond kleur ( label.backgroundColor = [UIColor clearColor]).
  • Gebruik bold 20pt systeem lettertype ( label.font = [UIFont boldSystemFontOfSize: 20.0f]).
  • Hebben een schaduw van zwart met 50% alfa ( label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]).
  • U wilt de tekst uitlijning gecentreerd evenals ingesteld ( label.textAlignment = NSTextAlignmentCenter( UITextAlignmentCentervoor oudere SDK's).

Stel de label tekstkleur te zijn wat aangepaste kleur die u wilt. U wilt een kleur die niet leidt tot de tekst om zich te mengen in de schaduw, die moeilijk te lezen zou zijn.

Ik werkte dit uit door middel van trial and error, maar de waarden die ik kwam met zijn uiteindelijk te simpel voor hen niet te zijn wat Apple geplukt. :)

Als u wilt om dit te verifiëren, laat deze code in initWithNibName:bundle:in PageThreeViewController.mvan Apple's NavBar monster . Dit zal de tekst met een geel label te vervangen. Dit moet niet te onderscheiden van de oorspronkelijke door de code van Apple, met uitzondering van de kleur.

- (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 = NSTextAlignmentCenter;
                           // ^-Use UITextAlignmentCenter for older SDKs.
        label.textColor = [UIColor yellowColor]; // change this color
        self.navigationItem.titleView = label;
        label.text = NSLocalizedString(@"PageThreeTitle", @"");
        [label sizeToFit];
    }

    return self;
}

Edit: Lees ook Erik B's antwoord hieronder. Mijn code toont het effect, maar zijn code biedt een eenvoudigere manier om dit te laten vallen in plaats op een bestaande weergave controller.

antwoordde op 07/03/2009 om 03:30
bron van user

stemmen
226

Ik weet dat dit een mooie oude draad, maar ik denk dat het nuttig om te weten voor nieuwe gebruikers zou zijn dat iOS 5 brengt een nieuw pand voor het vaststellen van de titel eigenschappen.

U kunt UINavigationBar gebruiken setTitleTextAttributesvoor het instellen van het lettertype, de kleur, offset, en schaduw kleur.

Daarnaast kunt u dezelfde standaard UINavigationBar Titel Tekstkenmerken voor alle ingesteld UINavigationBarsin uw applicatie.

Bijvoorbeeld als volgt:

NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                            [UIColor whiteColor],UITextAttributeTextColor, 
                                            [UIColor blackColor], UITextAttributeTextShadowColor, 
                                            [NSValue valueWithUIOffset:UIOffsetMake(-1, 0)], UITextAttributeTextShadowOffset, nil];

[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
antwoordde op 26/10/2011 om 23:16
bron van user

stemmen
180

In iOS 5 kunt u de navigatiebalk titel kleur op deze manier te veranderen:

navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor yellowColor]};
antwoordde op 26/02/2012 om 17:31
bron van user

stemmen
127

Op basis van het antwoord Steven Fisher's schreef ik dit stukje code:

- (void)setTitle:(NSString *)title
{
    [super setTitle:title];
    UILabel *titleView = (UILabel *)self.navigationItem.titleView;
    if (!titleView) {
        titleView = [[UILabel alloc] initWithFrame:CGRectZero];
        titleView.backgroundColor = [UIColor clearColor];
        titleView.font = [UIFont boldSystemFontOfSize:20.0];
        titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];

        titleView.textColor = [UIColor yellowColor]; // Change to desired color

        self.navigationItem.titleView = titleView;
        [titleView release];
    }
    titleView.text = title;
    [titleView sizeToFit];
}

Het voordeel van deze code, naast het omgaan met het frame naar behoren, is dat als je de titel van je controller verandert de aangepaste titel uitzicht zal ook worden bijgewerkt. Geen behoefte om het handmatig bijwerken.

Een ander groot voordeel is dat het maakt het heel eenvoudig om aangepaste titel kleur mogelijk te maken. Het enige wat u hoeft te doen is om deze methode toe te voegen aan de controller.

antwoordde op 05/05/2011 om 14:52
bron van user

stemmen
40

De meeste van de bovenstaande suggesties zijn nu verouderd, voor iOS 7 gebruik -

NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
                               [UIColor whiteColor],NSForegroundColorAttributeName, 
                               [UIColor whiteColor],NSBackgroundColorAttributeName,nil];

self.navigationController.navigationBar.titleTextAttributes = textAttributes;
self.title = @"Title of the Page";

Ook de kassa de NSAttributedString.h voor verscheidene text eigenschappen die kunnen worden ingesteld.

antwoordde op 03/10/2013 om 13:01
bron van user

stemmen
38

In iOS 7 en 8, kunt u de titel van kleur veranderen om laten we zeggen groen

self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor greenColor] forKey:NSForegroundColorAttributeName];
antwoordde op 19/12/2013 om 17:14
bron van user

stemmen
20

Op de vraag up-to-date te houden, zal ik voeg Alex RR oplossing, maar in Swift :

self.navigationController.navigationBar.barTintColor = .blueColor()
self.navigationController.navigationBar.tintColor = .whiteColor()
self.navigationController.navigationBar.titleTextAttributes = [
    NSForegroundColorAttributeName : UIColor.whiteColor()
]

Wat leidt tot:

voer image beschrijving hier

antwoordde op 14/08/2015 om 13:48
bron van user

stemmen
13

Werkwijze 1 , instellen IB:

voer image beschrijving hier

Werkwijze 2 , een regel code:

navigationController?.navigationBar.barTintColor = UIColor.blackColor()
antwoordde op 08/04/2016 om 13:45
bron van user

stemmen
13

Vanaf iOS 5 verder hebben we de titel tekstkleur en het lettertype van navigatiebalk met behulp van titleTextAttribute Dictionary (vooraf gedefinieerde woordenboek in UInavigation controller klasse referentie) in te stellen.

 [[UINavigationBar appearance] setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIColor blackColor],UITextAttributeTextColor, 
[UIFont fontWithName:@"ArialMT" size:16.0], UITextAttributeFont,nil]];
antwoordde op 11/09/2012 om 08:21
bron van user

stemmen
13

De oplossing van tewha werkt goed als je probeert om de kleur te veranderen op een pagina, maar ik wil in staat zijn om de kleur te veranderen op elke pagina. Ik maakte een aantal kleine aanpassingen, zodat het zou werken voor alle pagina's op eenUINavigationController

NavigationDelegate.h

//This will change the color of the navigation bar
#import <Foundation/Foundation.h>
@interface NavigationDelegate : NSObject<UINavigationControllerDelegate> {
}
@end

NavigationDelegate.m

#import "NavigationDelegate.h"
@implementation NavigationDelegate

- (void)navigationController:(UINavigationController *)navigationController 
      willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    CGRect frame = CGRectMake(0, 0, 200, 44);//TODO: Can we get the size of the text?
    UILabel* label = [[[UILabel alloc] initWithFrame:frame] 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];
    //The two lines below are the only ones that have changed
    label.text=viewController.title;
    viewController.navigationItem.titleView = label;
}
@end
antwoordde op 24/09/2010 om 03:56
bron van user

stemmen
10

Swift Version

Ik vond dat de meeste van jullie presenteerde de antwoorden van Objective_C versie

Ik zou graag van deze functie uit te voeren met behulp van Swift voor iedereen die het nodig heeft.

in viewDidLoad

1.To maken navigatiebalk achtergrond wordt kleur (bijvoorbeeld: BLAUW)

self.navigationController?.navigationBar.barTintColor = UIColor.blueColor()

2.To maken navigatiebalk achtergrond wordt afbeelding (bijvoorbeeld: ABC.png)

let barMetrix = UIBarMetrics(rawValue: 0)!

self.navigationController?.navigationBar
      .setBackgroundImage(UIImage(named: "ABC"), forBarMetrics: barMetrix)

3.To verandering navigatiebalk titel (bijvoorbeeld: [Font: Futura, 10] [Kleur: Red])

navigationController?.navigationBar.titleTextAttributes = [
            NSForegroundColorAttributeName : UIColor.redColor(),
            NSFontAttributeName : UIFont(name: "Futura", size: 10)!
        ]

(Hint1: "!" Vergeet niet het merk na de UIFont)

(Hint2: er zijn tal van attributen van de titel tekst, commando klik op de "NSFontAttributeName" kunt u de klasse en uitzicht keyNames en de objecten vormen ze verplicht in te voeren)

Ik hoop dat ik kan helpen: D

antwoordde op 09/10/2015 om 10:05
bron van user

stemmen
10

Met onderstaande code in elke weergave controller viewDidLoad of viewWillAppear werkwijze.

- (void)viewDidLoad
{
    [super viewDidLoad];

    //I am using UIColor yellowColor for an example but you can use whatever color you like   
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor yellowColor]};

    //change the title here to whatever you like
    self.title = @"Home";
    // Do any additional setup after loading the view.
}
antwoordde op 19/05/2014 om 07:43
bron van user

stemmen
9

Kort en zoet.

[[[self navigationController] navigationBar] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]}];
antwoordde op 08/12/2013 om 03:50
bron van user

stemmen
8

Dit is mijn oplossing op basis van Stevens

Enige echte verschil is dat ik er wat de behandeling voor de positie corrigeren indien afhankelijk van de lengte van de tekst, lijkt vergelijkbaar met hoe apple doen te zijn

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(([self.title length] < 10 ? UITextAlignmentCenter : UITextAlignmentLeft), 0, 480,44)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = [UIFont boldSystemFontOfSize: 20.0f];
titleLabel.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
titleLabel.textAlignment = ([self.title length] < 10 ? UITextAlignmentCenter : UITextAlignmentLeft);
titleLabel.textColor = [UIColor redColor];
titleLabel.text = self.title;
self.navigationItem.titleView = titleLabel;
[titleLabel release];

U kunt aanpassen van de 10 waarde afhankelijk van de grootte van het lettertype

antwoordde op 22/10/2010 om 15:28
bron van user

stemmen
6

Dit is een mooie oude draad, maar ik denk van het verstrekken van antwoord voor het instellen van kleur, grootte en verticale positie van navigatiebalk titel voor iOS 7 en hoger

Voor kleur en grootte

 NSDictionary *titleAttributes =@{
                                NSFontAttributeName :[UIFont fontWithName:@"Helvetica-Bold" size:14.0],
                                NSForegroundColorAttributeName : [UIColor whiteColor]
                                };

Voor de verticale

[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-10.0 forBarMetrics:UIBarMetricsDefault];

Stel Titel en wijs de attributen woordenboek

[[self navigationItem] setTitle:@"CLUBHOUSE"];
self.navigationController.navigationBar.titleTextAttributes = titleAttributes;
antwoordde op 04/06/2015 om 15:05
bron van user

stemmen
6

Het is aan te raden om self.title ingesteld als deze wordt gebruikt terwijl het duwen kind navigatiebalken of het tonen van titel op tabbars.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // create and customize title view
        self.title = NSLocalizedString(@"My Custom Title", @"");
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        titleLabel.text = self.title;
        titleLabel.font = [UIFont boldSystemFontOfSize:16];
        titleLabel.backgroundColor = [UIColor clearColor];
        titleLabel.textColor = [UIColor whiteColor];
        [titleLabel sizeToFit];
        self.navigationItem.titleView = titleLabel;
        [titleLabel release];
    }
}
antwoordde op 24/05/2012 om 19:50
bron van user

stemmen
6

Ik heb afbeelding achtergrond van de navigatiebalk's aangepast en linker knop item en de grijze titel niet passen in de achtergrond. Dan gebruik ik:

[self.navigationBar setTintColor:[UIColor darkGrayColor]];

de tint kleur grijs te veranderen. En de titel is nu wit! Dat is wat ik wil.

Hoop om ook helpen :)

antwoordde op 27/05/2011 om 06:37
bron van user

stemmen
6

Ik liep in het probleem met mijn nav de knoppen van de tekst uit het centrum te gooien (wanneer u slechts één knop). Om vast te stellen dat ik net mijn framemaat gewijzigd als volgt:

CGRect frame = CGRectMake(0, 0, [self.title sizeWithFont:[UIFont boldSystemFontOfSize:20.0]].width, 44);
antwoordde op 21/01/2011 om 17:07
bron van user

stemmen
4

Dit werkt voor mij in Swift:

navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white]
antwoordde op 13/04/2017 om 02:44
bron van user

stemmen
4

Gebruik als dit voor Orientation ondersteuning

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,40)];
 [view setBackgroundColor:[UIColor clearColor]];
 [view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ];

 UILabel *nameLabel = [[UILabel alloc] init];
 [nameLabel setFrame:CGRectMake(0, 0, 320, 40)];
 [nameLabel setBackgroundColor:[UIColor clearColor]];
 [nameLabel setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin |UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
 [nameLabel setTextColor:[UIColor whiteColor]];
 [nameLabel setFont:[UIFont boldSystemFontOfSize:17]];
  [nameLabel setText:titleString];
 [nameLabel setTextAlignment:UITextAlignmentCenter];
 [view addSubview:nameLabel];
 [nameLabel release];
 self.navigationItem.titleView = view;
 [view release];
antwoordde op 17/01/2011 om 06:28
bron van user

stemmen
3

Een update naar Alex RR's post met behulp van de nieuwe iOS 7 tekst attributen en modern Objective C voor minder lawaai:

NSShadow *titleShadow = [[NSShadow alloc] init];
titleShadow.shadowColor = [UIColor blackColor];
titleShadow.shadowOffset = CGSizeMake(-1, 0);
NSDictionary *navbarTitleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
                                            NSShadowAttributeName:titleShadow};

[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
antwoordde op 29/11/2013 om 23:35
bron van user

stemmen
3

lettergrootte van de titel te stellen die ik heb gebruikt volgende voorwaarden .. misschien behulpzaam voor iedereen

if ([currentTitle length]>24) msize = 10.0f;
    else if ([currentTitle length]>16) msize = 14.0f;
    else if ([currentTitle length]>12) msize = 18.0f;
antwoordde op 15/09/2011 om 12:18
bron van user

stemmen
2

Ik geloof dat de juiste manier om de kleur in te stellen van UINavigationBar is:

NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],UITextAttributeTextColor, nil];
self.titleTextAttributes = attributes;

Bovenstaande code is geschreven subklasse op UINavigationBar, uiteraard werkt zonder subklassen ook.

antwoordde op 09/07/2012 om 23:04
bron van user

stemmen
2

Na de ontmoeting met de zelfde probleem (zoals anderen) van het label dat beweegt wanneer we voegen een knop in de navigatiebalk (in mijn geval heb ik een spinner dat ik vervangen door een knop wanneer de datum is geladen), heeft de bovenstaande oplossingen niet werken voor mij, dus hier is wat werkte en het label gehouden op dezelfde plaats de hele tijd:

- (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
    //CGRect frame = CGRectMake(0, 0, [self.title sizeWithFont:[UIFont boldSystemFontOfSize:20.0]].width, 44);
   CGRect frame = CGRectMake(0, 0, 180, 44);
    UILabel *label = [[[UILabel alloc] initWithFrame:frame] 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];
    self.navigationItem.titleView = label;
    label.text = NSLocalizedString(@"Latest Questions", @"");
    [label sizeToFit];
}

return self;
antwoordde op 14/04/2011 om 22:23
bron van user

stemmen
2

Dit is één van die dingen die ontbreken. U kunt het beste is om je eigen aangepaste navigatiebalk maken, voegt u een tekstvak, en manipuleren van de kleur op die manier.

antwoordde op 01/03/2009 om 08:11
bron van user

stemmen
1
 self.navigationItem.title=@"Extras";
    [self.navigationController.navigationBar setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"HelveticaNeue" size:21],
      NSFontAttributeName,[UIColor whiteColor],UITextAttributeTextColor,nil]];
antwoordde op 30/10/2014 om 05:39
bron van user

stemmen
1

titleTextAttributes display attributen voor de titel tekst van de bar.

@property (nonatomic, kopiëren) NSDictionary * titleTextAttributes Discussie U kunt het lettertype, tekstkleur, tekst schaduw kleur en tekst schaduw offset voor de titel in de tekst te specificeren attributen woordenboek, met behulp van de tekst attribuut sleutels in NSString UIKit Toevoegingen Reference beschreven.

Beschikbaarheid Verkrijgbaar in iOS 5.0 en hoger. Aangegeven In UINavigationBar.h

antwoordde op 07/10/2012 om 06:51
bron van user

stemmen
1

Kan gebruik maken van deze methode in AppDelegate bestand en kan gebruiken bij elke view

+(UILabel *) navigationTitleLable:(NSString *)title
{
CGRect frame = CGRectMake(0, 0, 165, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = NAVIGATION_TITLE_LABLE_SIZE;
label.shadowColor = [UIColor whiteColor];
label.numberOfLines = 2;
label.lineBreakMode = UILineBreakModeTailTruncation;    
label.textAlignment = UITextAlignmentCenter;
[label setShadowOffset:CGSizeMake(0,1)]; 
label.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];

//label.text = NSLocalizedString(title, @"");

return label;
}
antwoordde op 20/08/2012 om 11:47
bron van user

stemmen
1

Je moet [label sizeToFit] noemen; na het instellen van de tekst om vreemde offsets te voorkomen wanneer het label automatisch wordt verplaatst in de titel het oog wanneer andere knoppen bezetten de nav bar.

antwoordde op 16/03/2011 om 06:11
bron van user

stemmen
0

Swift 4 versie:

self.navigationController.navigationBar.titleTextAttributes = [
        NSAttributedStringKey.foregroundColor: UIColor.green]
antwoordde op 23/06/2018 om 08:41
bron van user

stemmen
0

Ik ben met behulp van de onderstaande code voor de iOS-9 en zijn werken prima voor mij. Ik heb ook gebruik maken van schaduw kleur voor de titel.

self.navigationItem.title = @"MY NAV TITLE";
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[self.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                       [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
                                                       shadow, NSShadowAttributeName,
                                                       [UIFont fontWithName:@"HelveticaNeue-Light" size:21.0], NSFontAttributeName, nil]];

Moge dit je helpen.

Bedankt

antwoordde op 12/07/2016 om 06:40
bron van user

stemmen
0

Om geweldige oplossing Erik B's meer bruikbare over de verschillende UIViewControllers van uw app Ik raad het toevoegen van een categorie voor UIViewController te maken en te verklaren zijn setTitle: title methode binnen. Zo zult gij de titel kleurverandering op alle uitzicht controllers zonder de noodzaak van dubbel werk te krijgen.

Een ding om al op te merken is dat je niet hoeft [super setTitle: tilte]; in Erik's code en dat je nodig hebt om expliciet aan te roepen self.title = @ "mijn nieuwe titel" naar uw mening controllers voor deze methode te noemen

@implementation UIViewController (CustomeTitleColor)

- (void)setTitle:(NSString *)title
{
    UILabel *titleView = (UILabel *)self.navigationItem.titleView;
    if (!titleView) {
        titleView = [[UILabel alloc] initWithFrame:CGRectZero];
        titleView.backgroundColor = [UIColor clearColor];
        titleView.font = [UIFont boldSystemFontOfSize:20.0];
        titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];

        titleView.textColor = [UIColor blueColor]; // Change to desired color

        self.navigationItem.titleView = titleView;
        [titleView release];
    }
    titleView.text = title;
    [titleView sizeToFit];
}

@einde

antwoordde op 31/12/2012 om 11:48
bron van user

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more