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
273
votes
39 answers

How do I show/hide a UIBarButtonItem?

I created a toolbar in IB with several buttons. I would like to be able to hide/show one of the buttons depending on the state of the data in the main window. UIBarButtonItem doesn't have a hidden property, and any examples I've found so far for…
Sasha
  • 3,405
  • 4
  • 19
  • 21
252
votes
31 answers

Change color of Back button in navigation bar

I am trying to change the color of the Settings button to white, but can't get it to change. I've tried both of these: navigationItem.leftBarButtonItem?.tintColor = UIColor.whiteColor() navigationItem.backBarButtonItem?.tintColor =…
199
votes
39 answers

Removing the title text of an iOS UIBarButtonItem

What I wanted to do is to remove the text from the 'Back' button of a UIBarButtonItem, leaving only the blue chevron on the navigation bar. Keep in mind that I'm developing for iOS 7. I've tried several methods, including, but not limited to: This…
Pan Ziyue
  • 2,287
  • 2
  • 16
  • 17
181
votes
29 answers

Setting action for back button in navigation controller

I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the backbutton attribute it doesn't pay attention to them and…
Parrots
  • 26,658
  • 14
  • 59
  • 78
157
votes
12 answers

UIBarButtonItem in navigation bar programmatically?

I've been looking around for this solution for a while but haven't got any. e.g one solution is self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: .Stop, target: self, action: nil), animated: true) This code will add…
Rahul Sonvane
  • 3,737
  • 7
  • 18
  • 21
151
votes
16 answers

Change the font of a UIBarButtonItem

I have a UIBarButtonItem in my UIToolbar titled Done. Now I want to change the font from the default to "Trebuchet MS" with Bold. How can I do that?
Ankit Vyas
  • 7,507
  • 13
  • 56
  • 89
141
votes
8 answers

How to create fixed space and flexible space bar button items programmatically?

I want to create UIBarButtonItems programmatically and place these fixed space items between buttons.
Linux world
  • 3,750
  • 11
  • 44
  • 59
138
votes
4 answers

How big should a UIBarButtonItem image be?

I'm looking to create my own custom Sort By Date and Sort By Number buttons that I plan on placing in the navigation bar as the right button. How big should my image be to appropriately fill the space -- the UIBarItem documentation page doesn't list…
Epsilon Prime
  • 4,576
  • 5
  • 31
  • 34
101
votes
20 answers

xcode/storyboard: can't drag bar button to toolbar at top

I have a view controller that is the detail view of a table. When you click on the row of the table it takes you to the detail view. The detail view is embedded in a navigation controller such that there is a button at the upper left of the…
user1904273
  • 4,562
  • 11
  • 45
  • 96
99
votes
10 answers

Adding a UILabel to a UIToolbar

I'm trying to add a label to my toolbar. Button works great, however when I add the label object, it crashes. Any ideas? UIBarButtonItem *setDateRangeButton = [[UIBarButtonItem alloc] initWithTitle:@"Set date range" …
user8359
98
votes
6 answers

How to set the action for a UIBarButtonItem in Swift

How can the action for a custom UIBarButtonItem in Swift be set? The following code successfully places the button in the navigation bar: var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self,…
kmiklas
  • 13,085
  • 22
  • 67
  • 103
94
votes
8 answers

"Plain Style unsupported in a Navigation Item" warning with my customized Bar Button Item

I drag a Round Rect Button to the position of the right Bar Button Item, and set an image to the Round Rect Button. All works well, except the warning "Plain Style unsupported in a Navigation Item". Even if i select the style of the Bar Button Item…
lu yuan
  • 7,207
  • 9
  • 44
  • 78
91
votes
35 answers

How to remove all navigationbar back button title

When I push a UIViewController, it has some title in back button at new UIViewController, if the title has a lot of text, It does not look good in iPhone 4s So I want to remove it. If I add some code in prepareForSegue function, it is going to be a…
jansma
  • 1,605
  • 1
  • 15
  • 22
91
votes
12 answers

Add button to navigationbar programmatically

Hi I need to set the button on right side, in navigation bar, programatically , so that if I press the button I will perform some actions. I have created the navigation bar, programatically by; navBar=[[UINavigationBar…
mac
  • 4,760
  • 7
  • 31
  • 33
89
votes
9 answers

UIBarButtonItem with custom image and no border

I want to create a UIBarButtonItem with a custom image, but I don't want the border that iPhone adds, as my Image has a special border. It's the same as the back button but a forward button. This App is for an inHouse project, so I don't care if…
mongeta
  • 2,301
  • 2
  • 32
  • 42
1
2 3
99 100