0

ボタンをナビゲーションバーのタイトルとして表示するこのコードがあり、ボタンコードで、ボタンを外したテキストラベルのフォントを変更するコードを記述していますが、以下のコードでは正しいフォントバージョンを取得できませんでした。

UIButton *titleButton = [[UIButton alloc]init];
titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[titleButton setFrame:CGRectMake(0, 0, 170, 35)];
[titleButton setTitle:[NSString stringWithFormat:@"%@ %@",delegatee.selectedBook,delegatee.selectedChapter]forState:UIControlStateNormal];

titleButton.titleLabel.font =[UIFont fontWithName:@"Georgia" size:10.0f];
[titleButton addTarget:self action:@selector(ClickbtnChaperselection:)forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView = titleButton;

iput georgiaですが、正しいフォントを取得できませんでした。ありがとうございます。

4

3 に答える 3

1

これを試して :

UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeCustom];    
[titleButton setFrame:CGRectMake(0, 0, 170, 35)];
[titleButton setTitle:[NSString stringWithFormat:@"%@ %@",delegatee.selectedBook,delegatee.selectedChapter]forState:UIControlStateNormal];

titleButton.titleLabel.font =[UIFont fontWithName:@"Georgia" size:10.0f];
[titleButton addTarget:self action:@selector(ClickbtnChaperselection:)forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView = titleButton;
于 2012-05-18T10:29:22.853 に答える
0

タイトルにボタンの代わりにラベルを貼ってみませんか?

タイトルラベルのコードは次のとおりです。

UILabel *titleView = (UILabel *)self.navigationItem.titleView;
if (!titleView)
  {
    titleView = [[UILabel alloc] initWithFrame:CGRectZero];
    [titleView setBackgroundColor:[UIColor clearColor]];
    [titleView setFont:[UIFont fontWithName:@"Georgia" size:10.0f]];

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

UIButtonにする必要がある場合は、必要に応じてコードを調整するのはそれほど難しくありません。

幸運を !

于 2012-05-18T10:44:45.133 に答える
0

これを試して

ボタンの場合:- use in Navigation Title view , this is work IOS 4 and IOS 5、私は使用します....。

  UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeCustom];    
[titleButton setFrame:CGRectMake(0, 0, 170, 35)];
[titleButton setTitle:@"dee"forState:UIControlStateNormal];

 UIFont *font=[UIFont fontWithName:@"A_Nefel_Sereke" size:21];
titleButton.titleLabel.font =font;

titleButton.titleLabel.textColor = [UIColor redColor];
[titleButton addTarget:self action:@selector(ClickbtnChaperselection:)forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView = titleButton;

フォント名に問題があると思います...確認してください

于 2012-05-18T10:48:23.557 に答える