uibarbuttonitem

iOS 7 BarButtonItem with image and title

女生的网名这么多〃 提交于 2019-11-27 01:02:49
问题 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

Custom UIBarButtonItem alignment off with iOS7

本秂侑毒 提交于 2019-11-27 00:30:45
问题 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 (

iPhone : making UIBarButtonItem that is arrow shaped

纵然是瞬间 提交于 2019-11-27 00:24:18
问题 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! 回答1: 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

Can I have a UIBarButtonItem with a colored image?

爷,独闯天下 提交于 2019-11-27 00:02:21
问题 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! 回答1: 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

How to add Badges on UIBarbutton item?

非 Y 不嫁゛ 提交于 2019-11-26 23:56:42
Hi friends am new to iphone developing. Am struggle with add badge values on UIBarbutton item on right side. I have tried but i can't solve this problem. Can anyone help me. Thanks in advance! I know this post is pretty old but with iOS7, MKNumberBadgeView's appearance does not really match the tab bar item badge design. I have found this other component which herits UIBarButtonItem and do the job very well : https://github.com/TanguyAladenise/BBBadgeBarButtonItem Hope this may help other iOS7 developers like me Yuvaraj.M Finally i found the way to add badges on UIBarbutton item. I searched

Hide UIToolbar UIBarButtonItems

谁说我不能喝 提交于 2019-11-26 22:23:32
问题 I have a UIToolbar that I set up using IB with three buttons, left, middle and right. In some situations I would like to not display the middle button. Does anybody know of a way to hide a specific button on inside a UIToolBar? There is no hide property, all I can find is setEnable but this still leaves the button causing users to wonder what its purpose is. I would like to only display it in situations that it actually has a use. Thanks in advance! 回答1: Reset the items: -(void)setItems:

How to handle UINavigationControllers and UITabBarControllers iOS 6.1

ε祈祈猫儿з 提交于 2019-11-26 21:30:39
问题 I need a good explanation how can I handle the UINavigationControllers and the UITabBarControllers on iOS6.1 with StoryBoards. When I load my app (1st ViewController) I need if (FB login = success) it jumps with segues to the 2nd ViewController automatically. Here I think I can't use a UINavigationController like root, apple's HIG don't like it. I need a UITabBarController that connects to 3 UICollectionViewControllers (one tab for each one). I have to put the UITabBarController like root? If

How do I show/hide a UIBarButtonItem?

老子叫甜甜 提交于 2019-11-26 21:16:49
I created a toolbar in IB with several buttons. I would like to be able to hide/show one of the buttons depending on the state of the data in the main window. UIBarButtonItem doesn't have a hidden property, and any examples I've found so far for hiding them involve setting nav bar buttons to nil, which I don't think I want to do here because I may need to show the button again (not to mention that, if I connect my button to an IBOutlet, if I set that to nil I'm not sure how I'd get it back). Save your button in a strong outlet (let's call it myButton ) and do this to add/remove it: // Get the

UIBarButtonItem Custom view in UINavigationBar

戏子无情 提交于 2019-11-26 20:54:02
问题 I am making a custom bar buttons for uinavigationbar, I am using following code UIImageView *backImgView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chk_back.png"]]; [backImgView setUserInteractionEnabled:YES]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:backImgView]; [backButton setTarget:self]; [backButton setAction:@selector(BackBtn)]; checkIn_NavBar.topItem.leftBarButtonItem = backButton; The problem is it is not calling its action. What i am

Get the width of a UIBarButtonItem

匆匆过客 提交于 2019-11-26 19:56:18
问题 I'm trying to get the width of a UIBarButtonItem . This doesn't work: barbuttonitem.customView.frame.size.width And this won't work, either: barbuttonitem.width 回答1: What about this: UIBarButtonItem *item = /*...*/; UIView *view = [item valueForKey:@"view"]; CGFloat width = view? [view frame].size.width : (CGFloat)0.0; 回答2: I had the same problem. After a lot of tries I found something that worked! In my specific case, I needed to get the width of the first UIBarButtonItem from the navigation