uibarbuttonitem

How to set UIBarButtonItem alpha

喜欢而已 提交于 2019-12-05 07:14:34
let searchBtn = UIBarButtonItem(image: UIImage(named: "ic_search"), style: .plain, target: self, action: #selector(self.searchButton)) let moreBtn = UIBarButtonItem(image: UIImage(named: "ic_more"), style: .plain, target: self, action: #selector(self.moreButton)) self.navigationItem.rightBarButtonItems = [moreBtn, searchBtn] moreBtn.alpha = 0 //something like this not working class CodeToPass: QualityStandarts { let doesnt = "meanAnything" } I have two UIBarButtonItems. Which made manually. And i wanna animate alpha, when i click one of them. How can i do it? moreBtn.tintColor = UIColor.red

Auto Layout with UINavigationBar and UIBarButtonItem

感情迁移 提交于 2019-12-05 05:54:08
I like to create my views as standalone Xib files then instantiate them and add as subviews. So, when working with a UINavigationBar , I expected to be able to do the same thing, first creating my custom view - from the Xib - then adding it as a custom view to the UIBarButtonItem : UIBarButtonItem *anItem = [[UIBarButtonItem alloc] initWithCustomView:_myCustomView]; Then adding to the nav bar: self.navigationBar.topItem.rightBarButtonItems = @[ anItem, anotherItem ]; So far so good. Now, _myCustomView uses Auto Layout (AL) and I thought this would be no problem. Not the case. I've tried just

How to change UIBarButtonItem's type in UINaviagationBar at runtime?

人盡茶涼 提交于 2019-12-05 04:21:09
I am working on an iPhone's view which composed 3 elements, UITextView, UIToolBar with an UIBarButtonItem. The goal is, I want UIBarButtonItem change its style from 'edit' (UIBarButtonSystemItemEdit) to 'Done' (UIBarButtonSystemItemDone) and update new selector to new method. First of all, I have tried following code but it doesn't work: Could you help me on this idea? There is a builtin bar button with this behaviour, you get it via the editButtonItem property of a UIViewContoller. Tabbing that button will change the view controller it came from into editing mode, and toggle the button into a

UIBarButtonItem Offset?

放肆的年华 提交于 2019-12-05 04:19:18
问题 I am trying to offset the UIBarButtonItems in my app, I need them slightly offset due to the image I use for my navigation bar so it all lines up correctly. I have managed to do this like so: [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-3 forBarMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearance] setBackgroundVerticalPositionAdjustment:-3 forBarMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearance] setBackButtonBackgroundVerticalPositionAdjustment:-3

iOS 7 UIBarButtonItem font changes when tapped

若如初见. 提交于 2019-12-05 03:44:02
I'm attempting to change my UIBarButtonItem font. It looks good when ViewControllers load. But if I tap on the bar button, or swipe right as if to move to the previous ViewController (but then pull back to the current one), the font changes back to the system font. Here's what I'm setting in my AppDelegate: NSDictionary* barButtonItemAttributes = @{NSFontAttributeName: [UIFont fontWithName:@"SourceSansPro-Light" size:20.0f]}; [[UIBarButtonItem appearance] setTitleTextAttributes: barButtonItemAttributes forState:UIControlStateNormal]; [[UIBarButtonItem appearance] setTitleTextAttributes:

UIBarButtonItem + popover segue creates multiple popovers

妖精的绣舞 提交于 2019-12-05 03:26:24
I've currently have an iPad app with a UIToolbar containing two UIBarButtonItems, each of which is connected to a popover segue. When the user touches either of the UIBarButtonItems, the popover is created rather than toggled. This creates multiple, overlapping popovers. I've been able to close the previously created popover using the following code - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // First close the preferences popover if it's open per Apple guidelines if ([self.popoverA.popoverController isPopoverVisible]) { [self.popoverA.popoverController

How to disable the the light that appears when touching a UIBarButtonItem?

二次信任 提交于 2019-12-05 01:34:18
问题 I have a toolbar with a UIBarButtonItem with style: UIBarButtonItemStylePlain . I wonder how can I disable the light that appears while touching it? UIButton has showsTouchWhenHighlighted property but there is no such a thing for UIBarButtonItem is there a work-around you might know? 回答1: In Interface Builder drag a UIButton to the toolbar. It will create a UIBarButtonItem with a UIButton in it. Set the type of the UIButton to custom. Then you can fully customize the appearence. For example

When changing UIBarButtonItem title, the transition is jerky/flickers

吃可爱长大的小学妹 提交于 2019-12-05 00:33:40
I have a UIViewController subclass. I give the view controller a rightBarButtonItem in viewDidLoad like this: self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Difficulty" style:UIBarButtonItemStylePlain target:nil action:nil]; When the user presses another button in the view, the title/text of the UIBarButtonItem is changed like this: self.navigationItem.rightBarButtonItem.title = @"Mellansvår"; It works fine, but when the title is changed, it doesn't look very good. The text jumps around a bit. I have changed UILabel text at runtime before, and when I change

Is there an easy way to change the text color of a UIBarButtonItem without using an image?

南笙酒味 提交于 2019-12-04 21:19:18
Is there an easy way to change the text color of a UIBarButtonItem without using an UIImage as the background? By default the text is always white. I'd like to make it black. The direct answer to your question is no. You can't simply change the color of a UIBarButtonItem by setting one of its properties. You can set the tintColor property of the UIToolBar or UINavigationBar that contains the UIBarButtonItem s, but that also affects the color of the toolbar itself and doesn't offer too much customization. If that doesn't work for you, a custom view as the other answers suggest is a fine idea.

Cannot set action on UIBarButtonItem

百般思念 提交于 2019-12-04 19:02:57
So I'm adding a bunch of custom UIBarButtonItems to a UIToolbar, and they all load just fine and look great, and I can see them in my UIToolbar. The only problem is, I can't perform any actions on them. In my viewDidLoad, I set up everything. Here are my .h and .m files: .h file: #import <UIKit/UIKit.h> #import <MobileCoreServices/MobileCoreServices.h> #import <QuartzCore/QuartzCore.h> @interface PhotoEditViewController : UIViewController <UIPopoverControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIGestureRecognizerDelegate> { IBOutlet UIImageView *imageView