uibarbuttonitem

iphone - How can I use an UIBarButtonItem style without the UIToolBar

非 Y 不嫁゛ 提交于 2019-12-06 00:31:23
Can I show a black style UIBarButtonItem in my view without the underneath UIToolBar? The UIToolBar always has a kind of border thing, I want the system UIBarButtonItem in black just like a black standard cancel button, but not the UIToolBar How can I do it? Thanks there is a cheeky hack that will help you with this. you want to use a UISegmentedControl with style set to UISegmentedControlStyleBar and only one item. You also need to setMomentary to yes - to make it behave like a button: UISegmentedControl *myCustomButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@

How do I prevent UIPopoverController passthroughViews from being reset after orientation change when presented from a UIBarButtonItem?

送分小仙女□ 提交于 2019-12-05 20:14:01
I have a UIPopoverController which is being presented from a UIBarButtonItem. I want touches outside of the popover to dismiss the popover. When presenting a popover from a bar button, the other bar buttons are automatically included in the popovers passthrough views. In order to prevent that I set the passthrough views to nil (or @[ ]) after presenting the popover, like so: - (IBAction) consoleBarButtonHit:(id)sender { UIViewController *consoleNavigationController=[self.storyboard instantiateViewControllerWithIdentifier:@"consoleNavigationController"]; _consolePopoverController=[

text color of disabled uibarbuttonitem is always the color of the normal state

ε祈祈猫儿з 提交于 2019-12-05 16:14:57
i wrote in my code [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:16.0f]} forState:UIControlStateDisabled]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blueColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:16.0f]} forState:UIControlStateNormal]; but the text color is always blue despite the baritem being disabled. I'm programming in

UIBarButtonItem remove Back Button Title - iOS 11

谁说我不能喝 提交于 2019-12-05 14:12:14
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), for:UIBarMetrics.default) I use above to remove the backButtonTitle prior to iOS 11. But on iOS 11 that is not properly working. Arrow shifts bit downwards. How to fix this? Edit: Other way by erasing Title can solve my problem but my concern is why that old way is not working anymore. The other way is to set UINavigationControllerDelegate for your navigationController and erase the title in its function. class NoBackButtonTitleNavigationDelegate: UINavigationControllerDelegate { func navigationController(

Hide the rightBarButtonItem of a navigation controller

Deadly 提交于 2019-12-05 13:11:56
问题 Does anyone know how to hide a rightBarButtonItem of a UINavigationController ? In my application, I have an edit button as a rightBarButtonItem of a UINavigationController . I want to hide this ? UIBarButton` when some operations are done. 回答1: To Hide the right button: self.navigationItem.rightBarButtonItem = nil; Now, to show it: If you setup the right button in your view controller by assigning it to self.editButtonItem then simply assign it again in order to show it: self.navigationItem

Explain this margin logic for leftBarButtonItem, rightBarButtonItem, titleView

倾然丶 夕夏残阳落幕 提交于 2019-12-05 10:20:16
Can anyone explain to me where the margins you see in this screen shot below are coming from? I want the red, green and blue rectangles to all fit next to each other in both screen layouts, landscape and portrait. Instead I see inexplicable margins between the views. // Setup Left Bar Button item UIBlankToolbar* tools = [[[UIBlankToolbar alloc] initWithFrame:CGRectMake(0, 0, 115, 44)] autorelease]; tools.autoresizingMask = UIViewAutoresizingFlexibleWidth; [tools setBackgroundColor:[UIColor greenColor]]; self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:tools]

iOS lazy var UIBarButtonItem target issue

允我心安 提交于 2019-12-05 08:58:26
I found this UIBarButtonItem target issue unconsciously when using lazy var initialization. class ViewController: UIViewController { lazy var barButtonItem1 = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(action1)) lazy var barButtonItem2: UIBarButtonItem = { let barButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(action2)) return barButtonItem } override func viewDidLoad() { super.viewDidLoad() print(barButtonItem1.target, barButtonItem2.target) } } The printed results showed that barButtonItem1.target was nil, and

add image to UIBarButtonItem for UIToolbar

自作多情 提交于 2019-12-05 07:33:29
问题 I am trying to add an image to the UIBarButtonItem which I have to use in a UIToolbar. I have managed to read the image and even get it to display with a UIImageView, but when i add it to the UIBarButtonItem and then add that item to the UIToolbar, the toolbar just displaces a "Blank White" space the size and shape of the image that I am trying to load. here is what I am trying. UIImage *image = [UIImage imageNamed:@"6.png"]; //This is the UIImageView that I was using to display the image so

UIBarButtonItem Highlighted Color

一曲冷凌霜 提交于 2019-12-05 07:28:49
I have set a custom tint color for a UINavigationBar (within a UINavigationController ) which, in turn, sets an appropriate matching color for the UIBarButtonItems which are inserted into the UINavigationBar . However, when I select a UIBarButtonItem the button turns into (presumably) the highlighted state and presents a different color, which looks quite a bit out and does not nicely match the tint color. Is there a way to change this highlighted state color to a custom color? Ideally, I would like to just create a category on UIBarButtonItem which changes the highlighted color for all

Adjust width of UITextField to fill toolbar in landscape

被刻印的时光 ゝ 提交于 2019-12-05 07:25:36
In a UIToolbar , I have added a UITextField to the middle of the bar (which gets added as a UIBarButtonItem ) with another UIBarButtonItem (Action button) next to it. I added flexible space bar button items at the very left and very right. It looks great on portrait, but when I rotate to landscape it centers them and looks ok, but I need the text field to get stretched to fill the width and push the last button clear to the right - exactly like it does in Messages - on iPhone and iPad. I thought Auto Layout would do the trick but Apple states you cannot create constraints for UIBarButtonItem s