アプリでナビゲーション バーのタイトルを中央に揃えようとしていますが、タイトルが右側にとどまっているようです (スクリーン ショットを参照してください)。以下のコードを使用しています。
-(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];
}
viewWillAppear()
以下のように
[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;
戻るボタンを非表示にすると、タイトルに中央揃えのタイトルが表示されます。戻るボタンの外観属性を設定する方法はありますか?
私が間違っていたかもしれない場所を誰かが私に案内してくれますか?