甲一个像素的发际线出现在工具栏的在IOS顶部边缘7
我切换我的应用程序从xcode的4.6至5甲一个像素的发际线出现在工具栏的在IOS顶部边缘7
我已经在具有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:@"[email protected]"] 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的顶部边缘我试图的所有功能。背景颜色,色调颜色,阴影图像,etc..Nothing解决了问题。
我也提到这个transition guidelines for bars in ios 7。
我发现在那里它提到了酒吧部分的外观属性,一个像素的发际线出现在iOS 7的顶部边缘,但它很烦人,如果有人不希望它应该被删除。
任何解决方案,以删除该行?
它看起来像这样
感谢MANIAK_dobrii用于提示一个伟大的工具revealapp,通过该工具的帮助下,我发现,在UIToolBar子视图层次中,有一个一个的UIImageView导致UIToolBar顶部的灰色线。
我看不见它使用下面的代码
[tools setBarTintColor:[UIColor clearColor]];
for(UIView *view in [tools subviews])
{
if([view isKindOfClass:[UIImageView class]])
{
[view setHidden:YES];
[view setAlpha:0.0f];
}
}
制成,解决了我的问题。
使用故事板....方式容易跟踪那些东西......没有额外的应用程序。这是iPhone故事板的快照。左侧的视图,按钮,标签层次结构.....'属性检查器'右侧的视图,按钮和标签的单独调整
通过在左侧使用视图层次结构,您无法在toolBars或其他uicontrols中看到子视图(内置或默认)。这里的故事板没有任何区别。 – ViruMax
尝试使用http://revealapp.com调查视图层次结构,它有帮助。 –
像这样去除阴影图像没有帮助? '[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];' – iNoob
@MANIAK_dobrii thanx,一个伟大的工具,我不知道这些工具,它显示它是UIToolBar本身的一部分。但不能解决问题的根源。 – ViruMax