ナビゲーション バーの高さを変更し、左上隅にカスタム イメージ ボタンを追加する必要があります。私は途中ですが、カスタム画像ボタンを正しい位置に配置することに迷っています。ここに私が持っているものがあります:
高さを調整するために、次の 1 つのメソッドで UINavBar カテゴリを作成しました。
- (CGSize)sizeThatFits:(CGSize)size {
CGSize newSize = CGSizeMake(768,80);
return newSize;
}
@end
ボタンを変更する UINavigationController サブクラスも作成しました。そのクラスの viewDidLoad は次のとおりです。
UIImage *navBackgroundImage = [UIImage imageNamed:@"bar"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
// Change the appearance of back button
UIImage *backButtonImage = [[UIImage imageNamed:@"back_off"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 6)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
// Change the appearance of other navigation button
UIImage *barButtonImage = [[UIImage imageNamed:@"menu_off"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
これまでのところ、このソリューションは上部のナビゲーション バーのサイズを変更しますが、ボタンを奇妙な位置に配置します。これが私が望むものと何が起こっているかです: