У меня есть такой дизайн панели навигации.Я уже увеличил высоту панели навигации, но как установить положение изображения кнопки «Назад» и выровнять его по левому краю?
#import "UINavigationBar+Custom.h"
@implementation UINavigationBar (Custom)
- (CGSize)sizeThatFits:(CGSize)size {
CGRect rec = self.frame;
CGRect screenRect = [[UIScreen mainScreen] bounds];
rec.size.width = screenRect.size.width;
rec.size.height = 77;
return rec.size;
}
@end
Дизайн изображения NavBar
![enter image description here](https://i.stack.imgur.com/46rNl.png)
Реальность
![enter image description here](https://i.stack.imgur.com/XVak6.png)
Обновление: Мой код для добавления кнопки "Назад"
- (void)viewDidLoad {
[super viewDidLoad];
[self configNavBar];
}
- (void)configNavBar {
// -- Config NavigationBar Background --
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
self.navigationController.navigationBar.translucent = NO;
// -- Navigator title font --
NSDictionary *titleAttributes = @{
NSFontAttributeName :FONT_NAVIGATION_TITLE_BAR,
NSForegroundColorAttributeName : [Utils colorWithHexString:@"#0f385a"] };
[self.navigationController.navigationBar setTitleTextAttributes:titleAttributes];
// -- Back button color --
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
UIImage *myImage = [UIImage imageNamed:@"ic_arrow_back"]; //set your backbutton imagename
UIImage *backButtonImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// now use the new backButtomImage
[[UINavigationBar appearance] setBackIndicatorImage:backButtonImage];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:backButtonImage];
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-0.f, -0)
forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundVerticalPositionAdjustment:40 forBarMetrics:UIBarMetricsDefault];
// -- Empty back title --
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backButtonItem];
}