uibarbuttonitem
Removing right bar button item from navigation item
What you’re doing should work. I’ve done that lots of times. Are you sure you’re removing the button from the correct navigation item? Is self the currently displayed UIViewController?
UIBarButtonItem image stays blue and not the original color of the image?
By default, image in UINavigationBar’s bar button items is rendered using template mode. You can set it to original. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@”info.png”] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(info:)];
UINavigationBar UIBarButtonItems much larger click area than required
This is the only solution I found. Create a container of the custom button: //Create a container for the button UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 55, 44)]; //Create a smaller button UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 55, 25)]; [closeButton setTitle:@”Cancel” forState:UIControlStateNormal]; //center the title closeButton.titleEdgeInsets = UIEdgeInsetsMake(23, 0, 0, 0); [buttonContainer … Read more
How to animate a button change in UINavigationBar?
self.navigationItem.rightBarButtonItem = self.addToOrderButton; There are specific methods you can use to animate the right and left bar button items: [self.navigationItem setRightBarButtonItem: self.addToOrderButton animated:YES]; …which will animate it for you. If you need everything to animate (including the title) you can also use the setItems:animated: method of your navigation bar (pass it in an array of … Read more
Can I have a UIBarButtonItem with a colored image?
There’s other iOS7+ solution: NSString *iconFilename = // … UIImage *image = [[UIImage imageNamed:iconFilename] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(onBarButtonItemTapped:)]; Swift 5: let iconFilename: String = // … let image = UIImage(named: iconFilename)?.withRenderingMode(.alwaysOriginal) let barButtonItem = UIBarButtonItem(image: image, style: .plain, target: self, action: #selector(onBarButtonItemTapped(_:))) Extract from UIImage.h: … navigation bars, tab … Read more
How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverController scheme on iPad apps?
Note: this no longer works as of iOS 11 In lieu of that mess with trying to find the UIBarButtonItem’s view in the toolbar’s subview list, you can also try this, once the item is added to the toolbar: [barButtonItem valueForKey:@”view”]; This uses the Key-Value Coding framework to access the UIBarButtonItem’s private _view variable, where … Read more