I have a custom navigationBar that i create inside a viewController. Before iOS 11 what i did was:
-(void)prepareNavigationbar{
[navigationBar removeFromSuperview];
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 7.0){
navigationBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 64)];
}
else{
navigationBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
}
navigationBar.tintColor = [UIColor blackColor];
navigationBar.barStyle = 1;
if ([navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
if (version>=7.0){
UIImage *gradientImage44 = [UIImage imageNamed:@"logostrip-568h"];
[[UINavigationBar appearance] setBackgroundImage:gradientImage44
forBarMetrics:UIBarMetricsDefault];
}
else{
UIImage *gradientImage44 = [UIImage imageNamed:@"logo-strip"];
[[UINavigationBar appearance] setBackgroundImage:gradientImage44
forBarMetrics:UIBarMetricsDefault];
}
}
else
{
//NSLog(@"enter in to old version");
[navigationBar drawRect:CGRectMake(0, 0, 320, 44)];
}
UINavigationItem *navigationItem = [[UINavigationItem alloc] init];
[navigationBar pushNavigationItem:navigationItem animated:NO];
[self.view addSubview:navigationBar];
}
The code works just fine until iOS 11. Now the issue is that the custom background seems to be smaller then the navigationBar.
Note - I'm using xibs and i dont have any StoryBoard.
How can i fix it?