How to make UIBarButtonSystemItem bordered? - objective-c

I have play UIBarButtonItem on UIToolbar. I want to make the style bordered. As it is system item, is there a way to make it bordered style?
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:#selector(play:)];

Set the UIBarButtonItem's style property:
systemItem1.style = UIBarButtonItemStyleBordered;
See the UIBarButtonItem class reference.

Related

Mimic XCode UIBarButtonItem init with an image

I was trying to create programmatically a UIBarButtonItem with an image.
I went like this :
[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"L-large-star#2x.png"] style:UIBarButtonItemStylePlain target:nil action:nil]
With that method my icon gets upscaled (and it's ugly). When I create that same button from the Interface Builder, the icon is a the right size (1/2 of the button).
Any idea how I could mimic this ?

Navigation Bar or ToolBar trouble in xcode

Ok I was looking at the iPhone iCal app, and was curious whether that top bar is a navigation bar or a toolbar? ive tried using both, but also i cannot figure out how to change the size of the buttons to be as small as the + button in the top right... very confused.. I'm assuming its a navigation bar, but when i read the description of the navigation bar, it said that whenever you are to add a button or item onto the bar, you cannot connect it directly... no idea how else to do it... but anyone wanna help with this issue?
If you are mentioning about this one
It is not UITabBar , it is UINavigationBar, the button on extreme left is inbuilt backbutton of UINavigationBar and the that at right is an extra button that you can add , its clearly shown in this question , and to change the type (ie, + button) you can simply change the button style using
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:#"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
adding button to UINavigationBar
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:#"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
rightButton.width=10;
rightButton.height=10;
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:#"Title"];
item.rightBarButtonItem = rightButton;
item.hidesBackButton = YES;
[bar pushNavigationItem:item animated:NO];
[rightButton release];
[item release];
But normally you would have a navigation controller, enabling you to write:
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:#"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
Hope this helps,
regards
The top bar with RED circle is UINavigationaBar & the bar with GREEN circle is custom designed.
You can the use the below written code to add the system defined Add button to UINavigationaBar
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:#"Done"
style:UIBarButtonSystemItemAdd target:nil action:nil];
I realized that in fact you do not need code to get the button to shrink to the size of the + button in the top right corner of the calendar app. In fact, once you are in the storyboard. Open up the utilities tab on the right. Then open the attributes inspector. and where it says Identifier, the drop down tab has options. Choose the add option.

Change UIBarButtonItem into Simple Icon

I am trying to display the "settings gear" instead of the word "Settings" in by navigation bar. Does anyone know how to do this? Thank you!
UIBarButtonItem *btnGo = [[UIBarButtonItem alloc] initWithTitle:#"Settings"
style:UIBarButtonItemStyleBordered target:self action:#selector(settingsAction)];
self.navigationItem.rightBarButtonItem = btnGo;
Unfortunately, there is no default way to get this image. You should use initWithImage:style:target:action:
and add an image of your own. You can make one yourself, or get pre-rolled from some where like Glyphish: http://www.glyphish.com
you can try making a UIButton first , setting the gear image on it and than
UIBarButtonItem *btnGo = [[UIBarButtonItem alloc] initWithCustomView:btn];

How to add round information button as a rightbarbuttonitem to navigation controller?

I have a navigation controller. I want to add a right bar button item to that navigation controller. I am able to add one, but I want a specific style: labeled 'i' and also round in shape. Is there any property to do that?
I think there is no property what you asked. But you can make a custom image and use this method.
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithImage:customImage style:UIBarButtonItemStylePlain target:self action:#selector(customButton:)];
addButton.enabled = YES;
self.navigationItem.rightBarButtonItem = addButton;
For more details you can refer UIBarButtonItem ClassReference.

setRightBarButtonItems iOS5 not working

I am using the new API for UINavigationItem setRightBarButtonItems like this:
UIBarButtonItem *buttonSettings = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"settings.png"]
style:UIBarButtonItemStylePlain
target:self
action:#selector(showSettings:)];
UIBarButtonItem *buttonLogout = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPageCurl target:self action:#selector(showSettings:)];
[[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObjects:buttonLogout, buttonSettings, nil]];
But, only 1 button (settings) is appearing and logout button is not appearing at all. What am I doing wrong?
Thanks
You are not allowed to do it:
UIBarButtonSystemItemPageCurl
The system page curl button.
This bar button image can be used only for bar button items placed on toolbars.
Available in iOS 4.0 and later.
Declared in UIBarButtonItem.h.