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
23
votes
2 answers

UIToolbar with UIBarButtonItem LayoutConstraint issue

I'm creating a UIToolbar with UIBarButtonItem in it programatically. I'm not using .xib or storyboard for this ViewController. Here's the code of how I created it. NSMutableArray *items = [[NSMutableArray alloc] init]; UIBarButtonItem…
23
votes
6 answers

How can I change the font color of a UIBarButton item?

I want to change the color to red.
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
23
votes
6 answers

image for nav bar button item swift

I want to display an image in the left hand side of my nav bar in swift. I have tried adding a nav bar button item and setting an image there. The problem is that I have to use a really small image for it to fit in the nav bar nicely. But making…
user2363025
  • 6,365
  • 19
  • 48
  • 89
23
votes
3 answers

UIBarButtonItem Image is not shown and instead a white rectangle in the size of image is shown, Why?

With whatever image I try to intialize the UIBarButtonItem, its just showing a white background in the size of the image. Even when I tired in interface builder, the result is the same. All these images when used with other objects works perfectly.…
wolverine
  • 2,967
  • 5
  • 31
  • 35
22
votes
4 answers

iOS rightBarButtonItem on UINavigationController in swift

I'm trying to put a rightBarButtonItem on a second view controller of an UINavigationViewController stack. I'm creating and setting the button in viewDidLoad of the view controller that I want to show. My actual code looks like this: override func…
21
votes
5 answers

Adjust vertical position of UIBarButtonItem title inside UIToolbar

Is it possible to adjust the title of a UIBarButtonItem inside an UIToolbar? I've tried the following lines of code without success: UIBarButtonItem.appearance().setTitlePositionAdjustment(UIOffset(horizontal: 30, vertical: 30), forBarMetrics:…
Antoine
  • 23,526
  • 11
  • 88
  • 94
20
votes
3 answers

Add spacing between UIToolbar

I have a toolbar that looks like the following: The issue is that it is kind of cluttered and therefore I would like to add some spacing to it. I tried doing: UIBarButtonItem *spacer = [[UIBarButtonItem alloc]…
adit
  • 32,574
  • 72
  • 229
  • 373
20
votes
3 answers

Get the frame of UIBarButtonItem in Swift?

how could I get the frame of a rightbarbuttonItem in swift? I found this : UIBarButtonItem: How can I find its frame? but it says cannot convert NSString to UIView, or cannot convert NSString to String : let str : NSString = "view" //or type…
Paul
  • 6,108
  • 14
  • 72
  • 128
20
votes
7 answers

How to hide a bar button item for certain users

I have a settings bar button item (set as left bar button item). I only want to display it if the user is logged in. I thought I could use the following for anonymous users navigationItem.leftBarButtonItem = nil But then how would I show it as soon…
grabury
  • 4,797
  • 14
  • 67
  • 125
20
votes
8 answers

UINavigationBar BarButtonItem with Plain Style

i got the following code: - (id)init { if (self = [super init]) { self.title = @"please wait"; UIBarButtonItem *favorite = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"star.png"] style:UIBarButtonItemStylePlain…
choise
  • 24,636
  • 19
  • 75
  • 131
20
votes
2 answers

UIBarButtonItem Custom view in UINavigationBar

I am making a custom bar buttons for uinavigationbar, I am using following code UIImageView *backImgView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chk_back.png"]]; [backImgView setUserInteractionEnabled:YES]; UIBarButtonItem…
Hassy
  • 5,068
  • 5
  • 38
  • 63
19
votes
8 answers

How to fire uibarbuttonitem click event programmatically

I have created a UIActionSheet UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@"" delegate:self cancelButtonTitle:…
Jean Paul
  • 2,389
  • 5
  • 27
  • 37
19
votes
6 answers

Change the height of NavigationBar and UIBarButtonItem elements inside it in Cocoa Touch

I suppose it's not strictly in line with Apple guidelines but I guess it must be possible somehow. I'd like to change the height of navigation bar inside UINavigationController and the height of UIBarButtonItem elements inside that bar. Using a…
mgamer
  • 13,580
  • 25
  • 87
  • 145
19
votes
4 answers

Adding a UIBarButtonItem programmatically to UINavigationBar

I dropped in a UINavigationBar in UIInterfaceBuilder. I present this view modally and just want a UIBackBarButton to return to my last view. I have an outlet and property to this UINavigationBar declared. I thought in my viewDidLoad method, I…
Crystal
  • 28,460
  • 62
  • 219
  • 393
19
votes
4 answers

Changing the tint colour of elements in UINavigationbar (iOS 11)

I have been using this code to change the tint color of element in the navigation bar: UINavigationBar.appearance().tintColor = theme.labelColor However, this is no longer working in iOS 11. Before iOS 11, buttons in the Navigation Bar were…
Dan
  • 303
  • 3
  • 15