uibarbuttonitem

Custom “Pressed” UIBarButtonItem Backgrounds

笑着哭i 提交于 2019-11-29 04:19:23
I'm trying to set a custom pressed image for my UIBarButtonItem but nothing seems to be working. From my understanding, the code below should work, but despite setting the image for the highlighted state, the button looks exactly the same when pressed. Any ideas? UIImage *barButtonBackground = [[UIImage imageNamed:ANBarButtonItemBackgroundImageName] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0f,5.0f, 5.0f, 5.0f)]; UIImage *barButtonPressedBackground = [[UIImage imageNamed:ANBarButtonPressedImageName] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0f,5.0f, 5.0f, 5.0f)]; [self.navigationItem

How can we put two line in UIBarButtonItem in Navigation Bar

不想你离开。 提交于 2019-11-29 04:10:01
"Now Playing" is in One line in UIBarButtonItem. I have to put it in two lines, like "Now" is ay top and "Playing" is at bottom.I have written the following line of code:- UIBarButtonItem *flipButton = [[UIBarButtonItem alloc] initWithTitle:@"Now Playing" style:UIBarButtonItemStyleBordered target:self action:@selector(flipView)]; self.navigationItem.rightBarButtonItem = flipButton; So i want to pu line break in between "Now Playing". So please help me out. Yes you can. It is fairly simple to do. Create a multiline button and use that. The "trick" is to set the titleLabel numberOfLines property

iPhone: UINavigationBar with buttons - adjust the height

爱⌒轻易说出口 提交于 2019-11-29 03:24:26
问题 I am working on an iPhone application which works in both orientations: portrait and landscape. I am using for one view and tableview embedded in an UINavigationController. The height of this navigationbar with its buttons is either: 44px portrait or 34px landscape. Within a different view I created the UINavigationBar by myself and I am able to set the frame for the correct size, but the embedded UINavigationItem with UIBarButtonItem doesn't shrink. So for the 34 px in the landscape mode

Custom background/transparent background on UIBarButtonItem?

末鹿安然 提交于 2019-11-29 01:52:24
How is this effect achieved? Code snippets are highly welcome. This can be seen in Notes app and other apps on the App Store. It seem that either the buttons on the navigation controller are transparent and show the custom background of the navigation controller or that they themselves have a custom background applied to them. Any ideas on how this is achieved? EDIT: Here is an example from the iBooks app for the iPhone. As you can see, not only the UIButtons, but also the segmented control have custom backgrounds. I'm thinking that there is a way to globally set transparency/background to

Navigation bar with multiple buttons

爱⌒轻易说出口 提交于 2019-11-29 01:14:13
I have a navigation bar with a left and right button, and I need to put another button next to the right button. Does anyone know how I can go about this? Here is some code to help: - (id)init { self = [super initWithStyle:UITableViewStyleGrouped]; if (self) { _pinArray = [[NSArray alloc]init]; _pinArray = [Data singleton].annotations; UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithTitle:@"Map" style:UIBarButtonItemStylePlain target:self action:@selector(goToMap:)]; self.navigationItem.rightBarButtonItem = right; UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"Menu"

Custom UIBarButtonItems from UIButtons with custom images - is it possible to make the tap targets larger?

两盒软妹~` 提交于 2019-11-28 23:25:27
I'm making UIBarButtons as follows: // Create "back" UIBarButtonItem UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; backButton.frame = CGRectMake(0, 0, 28, 17); [backButton addTarget:self action:@selector(backButtonTapped) forControlEvents:UIControlEventTouchUpInside]; backButton.showsTouchWhenHighlighted = YES; UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal]; UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; [toolBarItems addObject

Changing the Tint Color of UIBarButtonItem

霸气de小男生 提交于 2019-11-28 22:21:22
I have a project using Storyboards and whenever I push a view controller with a segue, the dynamically created bar button item is always blue. It's driving me nuts. Because this object is created dynamically, I cannot set its color in IB (like I have done with previous bar button items). Among the solutions I have tried are: Set it in the receiver's viewDidLoad Set it in the receiver's viewDidAppear self.navigationItem.backBarButtonItem.tintColor = [UIColor whiteColor]; When I saw that didn't quite work, I tried setting the leftBarButtonItem instead: self.navigationItem.leftBarButtonItem

How to set target and action for UIBarButtonItem at runtime

你。 提交于 2019-11-28 22:16:43
Tried this but only works for UIButton: [btn setTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; Just set the UIBarButtonItem's target and action properties directly. UIBarButtonItem doesnt have the same addTarget method so you have to set them directly as follows btn.target = self; btn.action = @selector(barButtonCustomPressed:); ... // can specify UIBarButtonItem instead of id for this case -(IBAction)barButtonCustomPressed:(UIBarButtonItem*)btn { NSLog(@"button tapped %@", btn.title); } I ran into a similar problem... I assume you mean that if your

UINavigationBar BarButtonItem with Plain Style

拜拜、爱过 提交于 2019-11-28 20:29:04
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 target:self action:@selector(buttonFavoriteClicked:)]; self.navigationItem.rightBarButtonItem = favorite; } return self; } but my button looks still like a Button with UIBarButtonItemStyleBordered is there a way to set a button with plain style at this position? Create a UIButton in interface builder, make it look like exactly what you want. Create an outlet for in in

Placing a custom view based UIBarButtonItem in the navigation bar without default horizontal padding

China☆狼群 提交于 2019-11-28 19:46:44
问题 How do I remove the horizontal padding to the left and right of custom left and right UINavigationBar items? There seems to be ~ 10 points of padding that iOS sets by default. I'm customizing left and right navigation bar buttons (I have given up on trying to set my own backButtonItem, so I'm just using the leftBarButtonItem). In either case (left or right), pressing these custom buttons indicates that Apple seems to preserve some padding to the left of the leftBarButtonItem, and to the right