ios Titel und Untertitel in der Navigationsleiste zentriert

Ich versuche, zwei UILabels in meiner navigation bar, anstatt nur einer.

Ich folgte diesem link, um Informationen auf, wie das geht:
iPhone Titel und Untertitel in der Navigation Bar

Funktioniert es gut, aber ich kann nicht meine Texte zentriert werden, richtig.
Es ist in der Mitte zwischen den Tasten, aber die Standard-Titel-Verhalten ist die Mitte sich direkt unter der Zeit.

ios Titel und Untertitel in der Navigationsleiste zentriert

Hatte ich mal hier, dieselbe Frage, aber keine Antwort:
UINavigationBar TitleView mit Untertitel

Was bin ich?
Hier ist mein code:

CGRect headerTitleSubtitleFrame = CGRectMake(0, 0, 200, 44);
UIView* _headerTitleSubtitleView = [[UILabel alloc] initWithFrame:headerTitleSubtitleFrame];
_headerTitleSubtitleView.backgroundColor = [UIColor clearColor];
_headerTitleSubtitleView.autoresizesSubviews = NO;

CGRect titleFrame = CGRectMake(0, 2, 200, 24);
UILabel *titleView = [[UILabel alloc] initWithFrame:titleFrame];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20];
titleView.textAlignment = NSTextAlignmentCenter;
titleView.textColor = [UIColor whiteColor];
titleView.shadowColor = [UIColor darkGrayColor];
titleView.shadowOffset = CGSizeMake(0, -1);
titleView.text = @"Title";
titleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:titleView];

CGRect subtitleFrame = CGRectMake(0, 24, 200, 44-24);
UILabel *subtitleView = [[UILabel alloc] initWithFrame:subtitleFrame];
subtitleView.backgroundColor = [UIColor clearColor];
subtitleView.font = [UIFont boldSystemFontOfSize:13];
subtitleView.textAlignment = NSTextAlignmentCenter;
subtitleView.textColor = [UIColor whiteColor];
subtitleView.shadowColor = [UIColor darkGrayColor];
subtitleView.shadowOffset = CGSizeMake(0, -1);
subtitleView.text = @"Subtitle";
subtitleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:subtitleView];

self.navigationItem.titleView = _headerTitleSubtitleView;

InformationsquelleAutor user2700551 | 2013-08-20

Schreibe einen Kommentar