uibarbuttonitem

titleTextAttributes UIAppearance font in iOS 7

北慕城南 提交于 2019-11-28 05:47:49
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) Where the result in iOS 6 is: { NSFont = "<UICFFont: 0x1d897a80> font-family: \"My_Font\"; font-weight:

UINavigationBar UIBarButtonItems much larger click area than required

和自甴很熟 提交于 2019-11-28 05:45:11
hopefully someone can help me out- iv'e scoured the net for the answer and cannot find one- the UIBarButtonItems added to UINavigationBar have a much larger click area than required- for example, open up any project you have a nav bar with buttons on- click anywhere between the end of the button and the title of the nav bar- the button clicks, when you clearly did not click on the button- also try this- click underneath the nav bar, below the button, the button clicks for about 5+ pixels below the nav bar- my problem is this- i have added a custom header with buttons to a tableview- but when i

iOS 7 BarButtonItem with image and title

廉价感情. 提交于 2019-11-28 05:31:10
I'm trying to figure out how can I achieve something like this: This is a toolbar and I'd like to keep the button title text without having to create the whole image with icon AND text. How can I add the icon to the left of the UIBarButtonItem while keeping the text set with: UIBarButtonItem *customBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Button" style:UIBarButtonItemStyleBordered target:nil action:nil]; EDIT This is what I achieved with the following code: UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom]; [customButton setImage:[UIImage imageNamed:@"Test"]

Custom UIBarButtonItem alignment off with iOS7

别说谁变了你拦得住时间么 提交于 2019-11-28 04:34:37
So I am having the same problem that many others are experiencing when creating a UIBarButtonItem with a UIButton as a custom view. Basically the button is about 10 pixel to far either left or right. When I use a regular BarButtonItem without a custom view, this does not happen. This post provided a partial solution: UIBarButton With Custom View Here is my code I have created by subclassing UIButton (as stated in the other post) - (UIEdgeInsets)alignmentRectInsets { UIEdgeInsets insets; if ([self isLeftButton]) { insets = UIEdgeInsetsMake(0, 9.0f, 0, 0); } else { // IF ITS A RIGHT BUTTON

iPhone : making UIBarButtonItem that is arrow shaped

时光毁灭记忆、已成空白 提交于 2019-11-28 04:25:41
I have a UIBarButtonItem on a navigation bar. I'd like to make it arrow shaped. By that I mean I want it to be square except for a pointy side. Does anyone know how to do this? Thanks! Huygir I wrestled with several approaches on this one and finally figured it out using all the answers from several sources. There are a couple of tricks; this snippet will show it all (I was creating a custom rightNavButton , but you can adapt this easily for any UIBarButtonItem ): // Produces a nice "right arrow" style button that mirrors the back arrow // automatically added by the navController // UIImage

How do I hide/show the right button in the Navigation Bar

做~自己de王妃 提交于 2019-11-28 03:56:22
I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options. Unfortunately, the following doesn't work: NO GOOD: self.navigationItem.rightBarButtonItem.hidden = YES; // FOO CODE Is there a way? Hide the button by setting the reference to nil, however if you want to restore it later, you'll need to hang onto a copy of it so you can reassign it. UIBarButtonItem *oldButton = self.navigationItem.rightBarButtonItem; [oldButton retain]; self.navigationItem.rightBarButtonItem = nil; //... later self.navigationItem.rightBarButtonItem = oldButton;

UIBarButtonItem with UIImage Always Tinted iOS 7

 ̄綄美尐妖づ 提交于 2019-11-28 03:32:20
I'm trying to add a UIBarButtonItem containing a UIImage to a UIToolbar . The image keeps being tinted and I can't get it to show as the original colored image - all I want to do is display an image, verbatim, in a UIBarButtonItem ! I'm following the directions in the iOS 7 transition guide to set the image rendering mode to UIImageRenderingModeAlwaysOriginal . UIImage *image = [UIImage imageNamed:@"myImage.png"]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem *ratingImage = [[UIBarButtonItem alloc] initWithImage:image style

Can I have a UIBarButtonItem with a colored image?

廉价感情. 提交于 2019-11-28 03:23:53
I have an image that I want to display on a UIBarButtonItem, but for some reason it only shows the outline of it and the rest is all white. How can I have it actually display the image? Thanks! amrox UPDATE: See MANIAK_dobrii's answer for an easier solution, available in iOS 7+. Here is how I use an image for a UIBarButtonItem: UIImage *image = [UIImage imageNamed:@"buttonImage.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.bounds = CGRectMake( 0, 0, image.size.width, image.size.height ); [button setImage:image forState:UIControlStateNormal]; [button addTarget

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

半城伤御伤魂 提交于 2019-11-28 03:22:51
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! Here's an example that creates a toolbar button from the Facebook logo. Create a pointer to an image (file already added to xCode),

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

余生长醉 提交于 2019-11-28 03:08:45
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 the button reveals a popover controller where the user selected either "undo" or "redo" until the