Reputation: 1218
I switched my app from xcode 4.6 to 5.
I have added UIToolBar at right side of navigationbar having 3 buttons and I have used following code for that.
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];
The problem is a one-pixel hairline appears at the top edge in iOS 7. I tried all functions background color, tint color, shadow image, etc..Nothing solved my problem.
I also referred this transition guidelines for bars in ios 7.
I found that there it is mentioned under Bars section against appearance property that a one-pixel hairline appears at the top edge in iOS 7 but it is annoying and if someone dont want that it should get removed.
Any solution to remove that line?
it looks like this
Upvotes: 0
Views: 525
Reputation:
Use the Storyboards....way easy to keep track of that stuff..without the extra app. Here is a snapshot of the iPhone storyboard. View, button, label hierarchy on left.....individual adjustments for views, buttons, and labels on right side in 'attributes inspector'
Upvotes: 0
Reputation: 1218
Thanks to MANIAK_dobrii for suggesting a great tool revealapp, by the help of that tool I found that in UIToolBar subviews hierarchy , there was an one UIImageView resulting in a gray colour line at top of UIToolBar.
I made it invisible using following code
[tools setBarTintColor:[UIColor clearColor]];
for(UIView *view in [tools subviews])
{
if([view isKindOfClass:[UIImageView class]])
{
[view setHidden:YES];
[view setAlpha:0.0f];
}
}
And solved my problem.
Upvotes: 1