uibarbuttonitem

Custom “Pressed” UIBarButtonItem Backgrounds

為{幸葍}努か 提交于 2019-12-18 04:09:41
问题 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

Add image to UIBarButtonItem button

ε祈祈猫儿з 提交于 2019-12-18 02:16:10
问题 I have added UITabButtonItem onto my view controller using following code. Could anyone please tell me if its possible to associate image with it? UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(favouriteButtonClicked:)]; viewController2.navigationItem.rightBarButtonItem = button; [button release]; [self.navigationController pushViewController:viewController2 animated:YES]; I use following code at other

Change the font of a UIBarButtonItem

社会主义新天地 提交于 2019-12-17 17:28:24
问题 I have a UIBarButtonItem in my UIToolbar titled Done . Now I want to change the font from the default to "Trebuchet MS" with Bold. How can I do that? 回答1: Because UIBarButtonItem inherits from UIBarItem, you can try - (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state but this is for iOS5 only. For iOS 3/4, you will have to use a custom view. 回答2: To be precise, this can be done as below [buttonItem setTitleTextAttributes:[NSDictionary

How to fire uibarbuttonitem click event programmatically

走远了吗. 提交于 2019-12-17 15:42:31
问题 I have created a UIActionSheet UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@"" delegate:self cancelButtonTitle: @"cancel" destructiveButtonTitle: @"OK" otherButtonTitles: nil]; [action showInView:self.view]; [action release]; On the event of the cancel button in the UIActionSheet I want to fire the event of a UIBarButtonItem , which is in my view. My question is how can I fire the button event(without touching the button) in the UIActionSheet delegate method 回答1: Not knowing

How do you add more than one UIBarButton on UINavigationItem.rightBarButtonItem (or leftBarButtonItem)?

徘徊边缘 提交于 2019-12-17 15:34:50
问题 I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ The problem is this leaves a faint seam. I tried setting the background image of the nested toolbar to an image I captured of what it should be. That didn't work. The image was not applied. I have also tried using a nested UINavigationBar and that didn't seem to work. I have seen this done in several iPhone apps. Does anyone know how? [EDIT] I want the buttons to look like normal UIBarButtonItems

How to Dismiss a Storyboard Popover

有些话、适合烂在心里 提交于 2019-12-17 08:10:37
问题 I've created a popover from a UIBarButtonItem using Xcode Storyboards (so there's no code) like this: Presenting the popover works just fine. However, I can't get the popover to disappear when I tap the UIBarButtonItem that made it appear. When the button is pressed (first time) the popover appears. When the button is pressed again (second time) the same popover appears on top of it, so now I have two popovers (or more if I continuer pressing the button). According to the iOS Human Interface

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

不羁的心 提交于 2019-12-17 08:02:42
问题 The following code works up through iOS 6: UIButton *myButton = nil; myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.bounds = CGRectMake(0,0,44,30); // setup myButton's images, etc. UIBarButtonItem *item = nil; item = [[UIBarButtonItem alloc] initWithCustomView:customButton]; This is how the button is supposed to be aligned: However, on iOS 7, the button appears to be offset from the right or left by too many pixels: How can I get my custom bar button items to be aligned

How to set image for bar button with swift?

五迷三道 提交于 2019-12-17 06:27:32
问题 I am trying to set an Image for bar button Item for that I have an image like: with resolution 30 * 30 but while I assign this Image to Bar button Its looks like: I have assigned image this way : and If I try this way like making an IBOutlet for the button and set Image programatically form this question and code for that is: // Outlet for bar button @IBOutlet weak var fbButton: UIBarButtonItem! // Set Image for bar button var backImg: UIImage = UIImage(named: "fb.png")! fbButton

How to add Badges on UIBarbutton item?

假装没事ソ 提交于 2019-12-17 06:24:26
问题 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! 回答1: 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

How do I show/hide a UIBarButtonItem?

岁酱吖の 提交于 2019-12-17 05:33:22
问题 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).