uibarbuttonitem

Get rid of the space on the right side of a UINavigationBar

喜欢而已 提交于 2019-12-01 06:39:38
So, this is what I'm trying to accomplish: It's a UINavigationBar with a UIBarButtonItem that gets initialized with a custom UIButton . Basically like this: UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; [favoriteButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; favoriteButton.frame = CGRectMake(0.0f, 0.0f, 44.0f, 44.0f); UIImage *backgroundImage = [[UIImage imageNamed:@"favorite-button-background-orange"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 2, 0, 0)]; [favoriteButton setBackgroundImage:backgroundImage forState

iOS11 UIBarButtonItem not working

我的未来我决定 提交于 2019-12-01 05:57:37
问题 I have an app that is live in the store. I am trying to get it ready for the iOS11 release but have run into an annoying problem. None of the UIBarButtonItem s in the app are working properly. The leftBarButtonItems are clickable but the click area is slightly to the right of the item. The rightBarButtonItems are not working at all! I have added the items both via the storyboard and via code but none of them seem to be working. Please help! Here's an example:- navigationItem

putting labels, buttons on the navigation bar iOS

霸气de小男生 提交于 2019-12-01 05:15:36
问题 I have created custom navigation controller, I want to be added, a date at the left, a back button on the right and the title next to back button. I tried to add one label, but it does not work. Please show me a way UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 66)]; UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,8,280,30)]; navLabel.text = @"My Text"; [self.navigationController.navigationBar addSubview:navLabel]; [self.view

Change the width of an UIBarButtonItem [duplicate]

心不动则不痛 提交于 2019-12-01 04:16:55
This question already has an answer here: Change width of a UIBarButtonItem in a UINavigationBar 6 answers Add image to UIBarButtonItem button 7 answers How can I change the width of an UIBarButtonItem to 29px? The property width does not work and I don't want to create a UIButton and use the initWithCustomView because I want the square background to adjust to the navigation bar color. I'm using the initWithImage to init the UIBarButtonItem . Here is my button with a current width of 37px. I want to set to 29px. you cant. If you want custom width you will need to use initWithCustomView You can

Change UIBarbuttonItems Color

一个人想着一个人 提交于 2019-12-01 03:39:30
How can I set UIBarButtonItem's color to green? I'm using iOS 4 , there is no tint property. please help me. In iOS 4: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal]; button.frame=CGRectMake(0.0, 100.0, 60.0, 30.0); [button setTitle:@"Green" forState:UIControlStateNormal]; [button addTarget:self action:@selector(yourAction) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithCustomView:button]; Here you need a green image for

Adding a UIBarButtonItem programmatically to UINavigationBar

夙愿已清 提交于 2019-12-01 02:17:46
I dropped in a UINavigationBar in UIInterfaceBuilder . I present this view modally and just want a UIBackBarButton to return to my last view. I have an outlet and property to this UINavigationBar declared. I thought in my viewDidLoad method, I could create a UIBackButton like this: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleBordered target:self action:@selector(goBack)]; self.navigationItem.backBarButtonItem = backButton; [backButton release]; But I do not see my UIBackBarButtonItem on the UINavigationBar . I think I am doing

Change the width of an UIBarButtonItem [duplicate]

∥☆過路亽.° 提交于 2019-12-01 01:09:47
问题 This question already has answers here : Change width of a UIBarButtonItem in a UINavigationBar (6 answers) Add image to UIBarButtonItem button (7 answers) Closed 6 years ago . How can I change the width of an UIBarButtonItem to 29px? The property width does not work and I don't want to create a UIButton and use the initWithCustomView because I want the square background to adjust to the navigation bar color. I'm using the initWithImage to init the UIBarButtonItem . Here is my button with a

How to do automated UI testing for system button on XCode7?

不问归期 提交于 2019-11-30 23:57:41
My Storyboard has only one UI, and it has navigation bar with one UIBarButtonItem with System Item: Add. It also has another info UIButton. When doing UI testing in English everything works good without any problem. But if you switch the language to another one, it is always failed. Here is the testing code snippet: app.navigationBars["My Product"].buttons["Add"].tap() app.buttons["More Info"].tap() According to the error log, Xcode find it in another language. Here it is: Assertion Failure: UI Testing Failure - No matches found for "More Info" Button Query input was Button 0x7fa4ca65a1d0:

Adding a UIBarButtonItem programmatically to UINavigationBar

社会主义新天地 提交于 2019-11-30 21:50:17
问题 I dropped in a UINavigationBar in UIInterfaceBuilder . I present this view modally and just want a UIBackBarButton to return to my last view. I have an outlet and property to this UINavigationBar declared. I thought in my viewDidLoad method, I could create a UIBackButton like this: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleBordered target:self action:@selector(goBack)]; self.navigationItem.backBarButtonItem = backButton; [backButton

Adding action and target to a custom Navigation BarButtonItem?

帅比萌擦擦* 提交于 2019-11-30 20:54:15
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]; [navItem setLeftBarButtonItem:myButtonItem animated:YES]; Looks good, except that now I can't set the