uibarbuttonitem

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

a 夏天 提交于 2019-11-27 05:07:10
问题 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 the UIToolbar UIImage *image = [UIImage imageNamed:@"6.png"]; UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(pp:)]; Thank You! 回答1: Here's an example that

How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverController scheme on iPad apps?

微笑、不失礼 提交于 2019-11-27 05:04:42
问题 Problem In my iPad app, I cannot attach a popover to a button bar item only after press-and-hold events. But this seems to be standard for undo/redo. How do other apps do this? Background I have an undo button (UIBarButtonSystemItemUndo) in the toolbar of my UIKit (iPad) app. When I press the undo button, it fires it's action which is undo:, and that executes correctly. However, the "standard UE convention" for undo/redo on iPad is that pressing undo executes an undo but pressing and holding

Change color of Back button in navigation bar

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 05:00:59
问题 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 = UIColor.whiteColor() but no change, it still looks like this: How do I make that button white? 回答1: You can change the global tint color in your storyboard by clicking on an empty space on the board and select in the right toolbar "Show the file inspector", and you

How to hide a bar button item for certain users

和自甴很熟 提交于 2019-11-27 03:51:28
问题 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 as they logged in? 回答1: You can store a copy of the leftBarButtonItem in a strong property and update it after the users log in. var leftBarButtonItem : UIBarButtonItem! Inside viewDidLoad : self.leftBarButtonItem = UIBarButtonItem(title: "test",

UIToolbar UIBarButtonItem with both image and title has very dim text

点点圈 提交于 2019-11-27 03:38:49
问题 My iPhone view adds some custom buttons to its toolbar. Each button has both an image and textual title, and is created like this: UIBarButtonItem *fooButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"foo.png"] style:UIBarButtonItemStylePlain target:self action:@selector(fooButtonPressed:)]; fooButton.title=@"Foo"; The title's text displays very dim; it looks like it has an alpha of about 0.5. If I use the default UIToolBar barStyle, I can't read the text at all. When

How big should a UIBarButtonItem image be?

时间秒杀一切 提交于 2019-11-27 02:39:00
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 anything about the size the image should be. As of iOS 11, the Human Interface Guidelines suggest glyphs be about 25×25 points in toolbars and navigation bars, up to a maximum of about 28 points. (And the HIG should definitely be in your bookmarks if you're working on iOS apps!) That would translate to images 25px square for older devices like iPad

Add a custom selector to a UIBarButtonItem

China☆狼群 提交于 2019-11-27 01:53:19
问题 I am an iOS newbie. I have a navigation bar button which when clicked should execute a function of my own. What is the best way to do that? UIBarButtonItem *doneBarButtonItem=[[UIBarButtonItem alloc] init]; doneBarButtonItem.title=@"Done"; self.navigationItem.rightBarButtonItem = doneBarButtonItem; [doneBarButtonItem release]; 回答1: One way is to init with the target and action: UIBarButtonItem *buttonHello = [[UIBarButtonItem alloc] initWithTitle:@"Say Hello" style

iPhone Set Tint Color of Back Bar Button Item

别来无恙 提交于 2019-11-27 01:50:53
问题 I am trying to set the tint color of the back button within a navigation controller, but nothing is working. I have tried [self.navigationController.backBarButtonItem setTintColor:myColor]; //myColor was previously set But it stays the default tint 回答1: I believe barButtonItem is read-only. (I'm not too sure about this, someone correct me if I'm wrong) To give a tint colour to these buttons, this is what I would do: In your App Delegate, add these lines of code: UIBarButtonItem

iphone - Custom UIBarButtonItem for back button

五迷三道 提交于 2019-11-27 01:11:41
问题 I am trying to use a custom item for the back button in my navigation bar. UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"]; UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithImage:backButtonImage style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationItem setBackBarButtonItem: customItem]; [customItem release]; What I end up getting is my image with a border around it. It looks like this (My image is the back button): How can I get rid of the

titleTextAttributes UIAppearance font in iOS 7

99封情书 提交于 2019-11-27 01:03:14
问题 I am using UIAppearance to apply fonts to UINavigationBar and UIBarButtonItem and I am having problems. I ran this code: [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTitleTextAttributes: @{NSFontAttributeName : [UIFont fontWithName:@"My_Font" size:17.0]} forState:UIControlStateNormal]; NSLog(@"%@", [[UIBarButtonItem appearanceWhenContainedIn: [UIToolbar class], nil] titleTextAttributesForState:UIControlStateNormal]); and the result of that log on iOS 7 is: (null)