清除UINavigationItem的底部边距

时间:2018-10-09 08:56:57

标签: ios objective-c uinavigationbar uinavigationitem

因此,我的应用有一个徽标,该徽标在iOS 9.3.5上显示为附加在导航栏的底部,但iOS 11似乎增加了下边距。您可以在屏幕截图上看到它:

Margin on iOS 9.3.5

Margin on iOS 11

我用以下代码添加徽标:

UIImage* imgAct = [UIImage imageNamed: @"icon.png"];

UIButton *viewAct = [UIButton buttonWithType:UIButtonTypeCustom];
[viewAct setImage:imgAct forState:UIControlStateNormal];
[viewAct setImage:imgAct forState:UIControlStateHighlighted];
[viewAct.imageView setContentMode:UIViewContentModeScaleAspectFit];
viewAct.frame =  CGRectMake(0.0, 0.0, 120, 48);
[viewAct setBackgroundColor:[UIColor whiteColor]];

UIBarButtonItem *btnAct = [[UIBarButtonItem alloc] initWithCustomView:viewAct];
UIImage *btnBg = [[UIImage imageNamed:@"white_pixel"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[btnAct setBackgroundImage:btnBg forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

[array addObject:btnAct];
self.navigationItem.leftBarButtonItems = array;

是否可以删除此空白或将我的徽标附加到iOS 11的底部?该应用程序很旧,并且不使用自动布局,所有导航栏都是以编程方式制作的。

0 个答案:

没有答案