gpt4 book ai didi

ios - UINaviationItem 中的 UIToolbar 顶部有奇怪的行

转载 作者:行者123 更新时间:2023-11-29 10:43:11 25 4
gpt4 key购买 nike

我试图通过以下方式在 UINavigationItem 的 titleView 中显示一个 UIToolbar:

UIBarButtonItem *mapItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"world_icon"]
style:UIBarButtonItemStylePlain
target:self action:@selector(hi)];
UIBarButtonItem *mapItem2 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"world_icon"]
style:UIBarButtonItemStylePlain
target:self action:@selector(hi)];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];

toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[toolbar setItems:@[mapItem, spaceItem, mapItem2, spaceItem]];
toolbar.backgroundColor = [UIColor clearColor];
toolbar.barStyle = UIBarStyleDefault;
[toolbar setBackgroundImage:[UIImage new]
forToolbarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
toolbar.tintColor = [UIColor whiteColor];

self.navigationItem.titleView = toolbar;

但是我在工具栏顶部看到了这条奇怪的黑线:

enter image description here

知道是什么原因造成的吗?谢谢!

最佳答案

我不知道这是怎么回事,但我遇到了和你一样的问题,我在使用中修复了它

toolbar.clipsToBounds = YES 

你也可以试试下面的

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
forBarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

关于ios - UINaviationItem 中的 UIToolbar 顶部有奇怪的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23442213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com