uibarbuttonitem

How to remove padding next to a UIBarButtonItem

◇◆丶佛笑我妖孽 提交于 2019-11-30 05:30:16
问题 I have added a custom button to the navigation bar's custom right bar button item as shown in the image. I'm want to be able to remove the space after the button so that it touches the right edge of the screen but couldn't find a solution even after searching. If someone could mention how, would be great. This is the code I'm using UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; aButton.frame = CGRectMake(50.0, 0.0, 60, 44); UIBarButtonItem *aBarButtonItem = [

iPhone: UINavigationBar with buttons - adjust the height

廉价感情. 提交于 2019-11-30 05:21:05
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 this button is to big and overlaps the navbar in the height. The funny thing is though, that this worked

Adding action and target to a custom Navigation BarButtonItem?

不羁的心 提交于 2019-11-30 04:55:16
问题 I am trying to customize the Navigation Bar by adding a custom button to the rightBarButtonItem. Creating one is pretty straight forward. UIImage *myImage = [UIImage imageNamed:@"menu-icon.png"]; UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; [myButton setFrame:CGRectMake(0, 0, myImage.size.width, myImage.size.height)]; [myButton setBackgroundImage:myImage forState:UIControlStateNormal]; UIBarButtonItem *myButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myButton];

Bar Button Item not correctly aligned

∥☆過路亽.° 提交于 2019-11-30 03:55:31
问题 I have an issue with my navigation bar, the UIBarButtonItem is not correctly vertically aligned. I don't know why because I'm using a simple UIBarButtonItem and not a custom view. See my code below and thanks for your help! UIBarButtonItem *newGameItem = [[UIBarButtonItem alloc] initWithTitle:@"New Game" style:UIBarButtonItemStyleDone target:self action:@selector(newGame)]; self.navigationItem.rightBarButtonItem = newGameItem; 回答1: Actually there are couple ways to align the bar buttons. Try

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

帅比萌擦擦* 提交于 2019-11-30 03:08:43
I want to change the color to red. Tim Isganitis This question was answered here . Basically, you have to create a UIButton, configure it as you wish, and then initialize the Bar Button Item with the UIButton as a custom view. Gavy I found a simpler way to just change the color of title: iOS7: UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"Title" style:UIBarButtonItemStyleBordered target:nil action:nil]; [button setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal]; and

Enabling done button after inserting one char in a textfield: textFieldDidEndEditing: or textFieldShouldBeginEditing: or?

☆樱花仙子☆ 提交于 2019-11-30 02:05:56
I would like to enable the done button on the navbar (in a modal view) when the user writes at least a char in a uitextfield. I tried: textFieldDidEndEditing: enables the button when the previous uitextfield resigns first responder (so with the zero chars in the current uitextfield). textFieldShouldBeginEditing: is called when the textfield becomes the first responder. Is there another way to do this? [EDIT] The solution could be -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string but neither [self.navigationItem

“Plain Style unsupported in a Navigation Item” warning with my customized Bar Button Item

*爱你&永不变心* 提交于 2019-11-30 00:12:56
I drag a Round Rect Button to the position of the right Bar Button Item, and set an image to the Round Rect Button. All works well, except the warning "Plain Style unsupported in a Navigation Item". Even if i select the style of the Bar Button Item to "Bordered", warning still be there. What's the matter with Xcode 4.2? Thanks in advance! Ps. I customized many Bar Button Items with Round Rect Button, some times Xcode 4.2 shows only one warning on a Bar Button Item, some times shows warnings on all Bar Button Items. I was able to remove these errors by manually editing the storyboard files and

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

妖精的绣舞 提交于 2019-11-29 22:48:40
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 of the rightBarButtonItem; regardless of how wide I make the custom background and image properties of

How to convert UIImage/CGImageRef's alpha channel to mask?

本秂侑毒 提交于 2019-11-29 21:56:29
How can I extract the alpha channel of a UIImage or CGImageRef and convert it into a mask that I can use with CGImageMaskCreate? For example: Essentially, given any image, I don't care about the colors inside the image. All I want is to create a grayscale image that represents the alpha channel. This image can then be used to mask other images. An example behavior of this is in the UIBarButtonItem when you supply it an icon image. According to the Apple docs it states: The images displayed on the bar are derived from this image. If this image is too large to fit on the bar, it is scaled to fit

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

喜夏-厌秋 提交于 2019-11-29 20:44:15
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 trick from this question I managed to change the height of navigation bar but I can see no way of adjusting the height of bar button items. If anyone knows how to change the size of bar button items, please help me out. Maybe this tutorial about a customized navbar will help you: Recreating the iBooks wood themed navigation bar If you create a