After removing the background of the toolbar, with an image mask, a shadow line still remains above the toolbar. How do we get rid of it? As you can see, by the image below, I want to use the toolbar and buttons but no background or top shadow.
const float colorMask[6] = {222, 255, 222, 255, 222, 255};
UIImage *_img = [[UIImage alloc] init];
UIImage *_maskedImage = [UIImage imageWithCGImage:CGImageCreateWithMaskingColors(_img.CGImage, colorMask)];
[self.navigationController.toolbar setBackgroundImage:_maskedImage forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
By default, android provides shadow for action bar. This example demonstrates How to remove shadow below the action bar. Step 1 - Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 - Add the following code to res/layout/activity_main.
You can remove the elevation from Material UI's AppBar by setting the elevation prop to 0.
None of the other answers worked on iOS7, some didn't seem to work consistently on older iOS versions either. This (paraphrasing http://samplecodebank.blogspot.com/2013/06/UIToolbar-setShadowImage-forToolbarPosition-example.html) works consistently on 5.1+ for me and is concise and more performant than generating custom background images and color masks.
toolbar.backgroundColor = [UIColor clearColor];
if ([toolbar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) {
[toolbar setBackgroundImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
}
if ([toolbar respondsToSelector:@selector(setShadowImage:forToolbarPosition:)]) {
[toolbar setShadowImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny];
}
On iOS 7, set [toolBar setClipsToBounds:YES]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With