Can I give a UIToolBar a custom background in my iPhone app?

Answering my own question here!!! Overriding the drawRect function and creating an implementation of the UIToolbar does the trick 🙂 @implementation UIToolbar (CustomImage) – (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed: @”nm010400.png”]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end

How to hide the navigation bar and toolbar as scroll down? Swift (like myBridge app)

Try this simple approach: Tested in Swift 3 func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { if(velocity.y>0) { //Code will work without the animation block.I am using animation block incase if you want to set any delay to it. UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: { self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.setToolbarHidden(true, animated: true) … Read more

Aligning UIToolBar items

Add two UIBarButtonSystemItemFlexibleSpace items to your toolbar, to the left and right of your items UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; [toolbar setItems:[NSArray arrayWithObjects:flexibleSpace, settingsButton,deleteButton,aboutButton, flexibleSpace, nil]]; Adding these as you would any other toolbar items will distribute space evenly between the two of them.

iOS 7 | Navigation bar / Toolbar buttons very close to status bar

The navigation bars or toolbars have to be at (0, viewController.topLayoutGuide.length) with bar positioning of UIBarPositionTopAttached. You should set the delegate of your navigation bar or your toolbar to your view controller, and return UIBarPositionTopAttached. If positioned correctly, you will have the result in your third image. More information here: https://developer.apple.com/documentation/uikit/uibarpositioningdelegate?language=objc

How do I show/hide a UIBarButtonItem?

Save your button in a strong outlet (let’s call it myButton) and do this to add/remove it: // Get the reference to the current toolbar buttons NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy]; // This is how you remove the button from the toolbar and animate it [toolbarButtons removeObject:self.myButton]; [self setToolbarItems:toolbarButtons animated:YES]; // This is how you … Read more

How can I add a toolbar above the keyboard?

UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 50)]; numberToolbar.barStyle = UIBarStyleBlackTranslucent; numberToolbar.items = [NSArray arrayWithObjects: [[UIBarButtonItem alloc]initWithTitle:@”Cancel” style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)], [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], [[UIBarButtonItem alloc]initWithTitle:@”Done” style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)], nil]; [numberToolbar sizeToFit]; phonenumberTextField.inputAccessoryView = numberToolbar; To Dismiss Keyboard: [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; Swift 3: let numberToolbar = UIToolbar(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, … Read more

How to draw a transparent UIToolbar or UINavigationBar in iOS7

Swift 3 (iOS 10) Transparent UIToolbar self.toolbar.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default) self.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any) Transparent UINavigationBar self.navigationBar.setBackgroundImage(UIImage(), for: .default) self.navigationBar.shadowImage = UIImage() self.navigationBar.isTranslucent = true Swift < 3 Transparent UIToolbar self.toolbar.setBackgroundImage(UIImage(), forToolbarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default) self.toolbar.setShadowImage(UIImage(), forToolbarPosition: UIBarPosition.Any) Transparent UINavigationBar self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default) self.navigationBar.shadowImage = UIImage() self.navigationBar.translucent = true Objective-C Transparent UIToolbar [self.toolbar setBackgroundImage:[UIImage new] … Read more

Creating a left-arrow button (like UINavigationBar’s “back” style) on a UIToolbar

I used the following psd that I derived from http://www.teehanlax.com/blog/?p=447 http://www.chrisandtennille.com/pictures/backbutton.psd I then just created a custom UIView that I use in the customView property of the toolbar item. Works well for me. Edit: As pointed out by PrairieHippo, maralbjo found that using the following, simple code did the trick (requires custom image in bundle) … Read more