gpt4 book ai didi

ios - ios 7工具栏顶部边缘出现一个像素的细线

转载 作者:行者123 更新时间:2023-11-29 03:11:36 30 4
gpt4 key购买 nike

我将我的应用程序从 xcode 4.6 切换到 5。

我在具有 3 个按钮的导航栏右侧添加了 UIToolBar,为此我使用了以下代码。

UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -25, 135, 44)];
//[tools setTintColor:[UIColor colorWithRed:54/255.0f green:54/255.0f blue:54/255.0f alpha:0.0]];

[tools setBackgroundColor:[UIColor clearColor]];
//[tools setBarTintColor:[UIColor whiteColor]];
[tools setAlpha:0.0f];
[tools setClearsContextBeforeDrawing:YES];
[tools setTintColor:[UIColor clearColor]];
[tools setTranslucent:YES];

[tools setBackgroundImage:[UIImage imageNamed:@"historyBg.png"] forToolbarPosition:UIToolbarPositionTop barMetrics:UIBarMetricsDefault];
[tools setShadowImage:[UIImage imageNamed:@"historyBg.png"] forToolbarPosition:UIToolbarPositionTop];
// Create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];

//Create volume control button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 30, 30);
[button addTarget:self action:@selector(volumeControlButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
button.showsTouchWhenHighlighted = YES;
[button setBackgroundImage:[UIImage imageNamed:@"icnVolumeControl.png"] forState:UIControlStateNormal];
UIBarButtonItem* bi = [[UIBarButtonItem alloc] initWithCustomView:button];
volumeControl = bi;

[buttons addObject:bi];

//Creates mute volume control button
btnToggleMute = [UIButton buttonWithType:UIButtonTypeCustom];
btnToggleMute.frame = CGRectMake(0, 0, 30, 30);
[btnToggleMute addTarget:self action:@selector(ToggleSound:) forControlEvents:UIControlEventTouchUpInside];
btnToggleMute.showsTouchWhenHighlighted = YES;
[btnToggleMute setBackgroundImage:[UIImage imageNamed:@"icnMuteVolume.png"] forState:UIControlStateNormal];
[btnToggleMute setBackgroundImage:[UIImage imageNamed:@"icnNotMute.png"] forState:UIControlStateSelected];

bi = [[UIBarButtonItem alloc] initWithCustomView:btnToggleMute];
[buttons addObject:bi];

button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 30, 30);
[button addTarget:self action:@selector(playLastPlayedVideo:) forControlEvents:UIControlEventTouchUpInside];
button.showsTouchWhenHighlighted = YES;
[button setBackgroundImage:[UIImage imageNamed:@"icnQuickPlay.png"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"icnQuickPlay@2x.png"] forState:UIControlStateSelected];

bi = [[UIBarButtonItem alloc] initWithCustomView:button];
[buttons addObject:bi];

// stick the buttons in the toolbar
[tools setItems:buttons animated:NO];

// and put the toolbar in the nav bar
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];

问题是在 iOS 7 的顶部边缘出现一个单像素的细线。我尝试了所有功能背景颜色、色调颜色、阴影图像等。没有解决我的问题。

我也提到了这个transition guidelines for bars in ios 7 .

我发现在 iOS 7 的顶部边缘出现一个单像素细线的 Bars 部分反对外观属性,但它很烦人,如果有人不希望它应该被删除。

有什么解决方案可以删除那条线吗?

看起来像这样

how it looks like

最佳答案

感谢 MANIAK_dobrii 推荐了一个很棒的工具 revealapp,在该工具的帮助下,我发现在 UIToolBar subview 层次结构中,有一个 UIImageView 导致 UIToolBar 顶部出现一条灰色线。

我使用下面的代码让它不可见

    [tools setBarTintColor:[UIColor clearColor]];
for(UIView *view in [tools subviews])
{
if([view isKindOfClass:[UIImageView class]])
{
[view setHidden:YES];
[view setAlpha:0.0f];
}
}

解决了我的问题。

关于ios - ios 7工具栏顶部边缘出现一个像素的细线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22190629/

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