Questions tagged [uibarbuttonitem]

UIBarButtonItem is a button specialized for placement on a UIToolbar or UINavigationBar object. It inherits basic button behavior from its abstract superclass, UIBarItem. The UIBarButtonItem defines additional initialisation methods and properties for use on toolbars and navigation bars. There are some methods for customizing Appearance. Available in iOS 2.0 and later in UIKit.

A bar button item is a button specialized for placement on a UIToolbar or UINavigationBar objects. It inherits basic button behavior from its abstract superclass, UIBarItem. The UIBarButtonItem defines additional initialization methods and properties for use on toolbars and navigation bars.

iOS includes a number of system-provided items with specific icons, but developers can create custom items as well.

Note: UIBarButtonItem is not a descendent of UIView, so many common tasks like applying animations or transforms can be more difficult than you might expect.

UIBarButtonItem Class Reference

2349 questions
84
votes
14 answers

How to Edit Empty Spaces of Left, Right UIBarButtonItem in UINavigationBar [iOS 7]

I was using iOS 6.1 earlier, but now I have moved to iOS 7. Along with other problems, I have observed that in my navigation bar, the left space of left bar button item and right empty space of the right button bar item are quite more in IOS 7 than…
Salman Zaidi
  • 9,342
  • 12
  • 44
  • 61
82
votes
14 answers

Changing back button in iOS 7 disables swipe to navigate back

I have an iOS 7 app where I am setting a custom back button like this: UIImage *backButtonImage = [UIImage imageNamed:@"back-button"]; UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton…
lehn0058
  • 19,977
  • 15
  • 69
  • 109
80
votes
11 answers

How to add multiple UIBarButtonItems on right side of Navigation Bar?

I would like to have more than a single UIBarButtonItem on the right side of my UINavigationBar. How can I achieve this? An example of what I am trying are shown below - you can notice that the top right has more than one button.
user1406716
  • 9,565
  • 22
  • 96
  • 151
75
votes
15 answers

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

The following code works up through iOS 6: UIButton *myButton = nil; myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.bounds = CGRectMake(0,0,44,30); // setup myButton's images, etc. UIBarButtonItem *item = nil; item =…
73
votes
6 answers

How to Dismiss a Storyboard Popover

I've created a popover from a UIBarButtonItem using Xcode Storyboards (so there's no code) like this: Presenting the popover works just fine. However, I can't get the popover to disappear when I tap the UIBarButtonItem that made it appear. When…
Sam Spencer
  • 8,492
  • 12
  • 76
  • 133
71
votes
17 answers

Swift Custom NavBar Back Button Image and Text

I need to customise the look of a back button in a Swift project. Here's what I have: Here's what I want: I've tried creating my own UIBarButtonItem but I can't figure out how to get the image to be beside the text, rather than as a background or…
Conor
  • 1,007
  • 1
  • 10
  • 16
71
votes
16 answers

How to set image for bar button with swift?

I am trying to set an Image for bar button Item for that I have an image like: with resolution 30 * 30 but while I assign this Image to Bar button Its looks like: I have assigned image this way : and If I try this way like making an IBOutlet for…
Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
70
votes
21 answers

Change position of UIBarButtonItem in UINavigationBar

How can I change the position of a UIBarButtonItem in a UINavigationBar? I would like my button to be about 5px higher than its normal position.
Ben Williams
  • 4,695
  • 9
  • 47
  • 72
70
votes
12 answers

How to set target and action for UIBarButtonItem at runtime

Tried this but only works for UIButton: [btn setTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
Sharief
  • 1,487
  • 2
  • 18
  • 26
67
votes
10 answers

add image to UIBarButtonItem using initWithImage:(UIImage *)image

I would like to know how to set an image to a UIBarButtonItem which will then be added to a UIToolbar, by using InitWithImage when creating a UIBarButtonItem. I am doing the following, but it creates a blank whitespace where the image should be on…
Shumais Ul Haq
  • 1,427
  • 1
  • 15
  • 26
63
votes
5 answers

UIBarButtonItem with UIImage Always Tinted iOS 7

I'm trying to add a UIBarButtonItem containing a UIImage to a UIToolbar. The image keeps being tinted and I can't get it to show as the original colored image - all I want to do is display an image, verbatim, in a UIBarButtonItem! I'm following…
DiscDev
  • 38,652
  • 20
  • 117
  • 133
60
votes
12 answers

How to programmatically set action for barButtonItem in swift 3?

Here is what I used previously, var barButtonItem = UIBarButtonItem(image: backImgs, style: UIBarButtonItemStyle.plain, target: self, action: Selector("menuButtonTapped:")) But there is some syntax changes for Swift 3.
Bhanupriya
  • 1,202
  • 1
  • 9
  • 20
51
votes
11 answers

Xcode 6 Storyboard Unwind Segue with Swift Not Connecting to Exit

When trying to connect a Navigation Bar Button to the Exit item of a ViewController in Xcode 6 (not really sure if it's an Xcode 6 problem but worth mentioning as it is in beta) it does not find the Swift function in the custom class. The function…
skabob11
  • 1,306
  • 1
  • 10
  • 19
50
votes
18 answers

How do I hide/show the right button in the Navigation Bar

I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options. Unfortunately, the following doesn't work: NO GOOD: self.navigationItem.rightBarButtonItem.hidden = YES; // FOO CODE Is there a way?
Lauren Quantrell
  • 2,647
  • 6
  • 36
  • 49
50
votes
3 answers

Show/Hide barButtonItem

I'm trying to show/hide a UIBarButtonItem. I added a barButton to the right side in the storyboard. Then in viewDidLoad, I made the rightBarButtonItem to nil. Later on, I set it to the button I added in the storyboard. Here's my code: // Right…
Jessica
  • 9,379
  • 14
  • 65
  • 136