uibarbuttonitem

Smaller active area for custom UIBarButtonItem

夙愿已清 提交于 2019-12-09 06:27:28
问题 I have a UINavigationBar with a custom UIBarButtonItem (which uses a UIButton as its custom view). The problem is: the active area of the custom button is much too large, if I tap at least 40 pixels outside the button, it still gets registered as a tap on the button. This results in accidental taps. How can I reduce the active area on these buttons? 回答1: I noticed this weirdness too. I found that using a container UIView fixes this. For example: UIButton *menuButton = [[UIButton alloc]

Swift add badge to navigation barButtonItem and UIButton

放肆的年华 提交于 2019-12-09 04:13:30
问题 I am trying to display badge on my notification button, in app as displayed on AppIcon. So far whatever i have researched is related to Obj. C, but nothing that specifically discussed way to implement that solution into Swift, Please help to find a solution to add a custom class / code to achieve Badge on UiBarbutton and UiButton. Researched so far: https://github.com/Marxon13/M13BadgeView along with MKBadge class etc. 回答1: There is a more elegant solution with an extension for UIButtonItem

Make a clear(transluscent) UIBarButttonItem IOS 5

时光总嘲笑我的痴心妄想 提交于 2019-12-09 02:15:36
I am trying to set the tint color for a UIBarButtonItem using the following code, but all I get is a black button. Is there a way to accomplish this without the need to use custom images? [[UIBarButtonItem appearance] SetTintColor:[UIColor clearColor]]: create a custom UIBarButtonItem with a button UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:buttonImage forState:UIControlStateNormal]; //set the frame of the button to the size of the image (see note below) button.frame = CGRectMake(0, 0, 24, 24); button.backgroundColor=[UIColor clearColor]; //create a

How to add UIBarButtonItem in UIToolBar in code

橙三吉。 提交于 2019-12-08 15:40:45
问题 I have standart UIBarButtonItem UIBarButtonItem *share = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share:)]; How to add her to UIToolBar? I've tried self.toolbarItems = [NSArray arrayWithObject:share]; But it doesn't work. Need your help. 回答1: Can you be more specific than "it doesn't work"? If you're trying to add an item to a toolbar that already has items, you'll need to modify the array of items: NSMutableArray *newItems

How to change UIBarButtonItem text during runtime “cleanly” (Edit --> Done --> Edit)?

人走茶凉 提交于 2019-12-08 10:20:12
问题 I'm trying to change UIBarButtonItem text "cleanly" during runtime so that Edit/Done modes can be toggled. Every time I change the title attribute during runtime, however, the animation seems clumsy. I'm looking to emulate the appearance and function of the Edit/Done button in the Contacts app (where Edit simply fades and Done appears in its place). @IBAction func editDoneButtonPressed(sender: UIBarButtonItem) { if(sender.title == "Edit"){ sender.title = "Done" }else{ sender.title = "Edit" }

Make a clear(transluscent) UIBarButttonItem IOS 5

冷暖自知 提交于 2019-12-08 04:09:03
问题 I am trying to set the tint color for a UIBarButtonItem using the following code, but all I get is a black button. Is there a way to accomplish this without the need to use custom images? [[UIBarButtonItem appearance] SetTintColor:[UIColor clearColor]]: 回答1: create a custom UIBarButtonItem with a button UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:buttonImage forState:UIControlStateNormal]; //set the frame of the button to the size of the image (see note

Can set background image for UIBarButtonItem in nav bar, but not bottom toolbar

梦想的初衷 提交于 2019-12-08 03:23:47
问题 So this works when adding the item to the nav bar, but when i add it to the toolbar set in the bottom bar via interface builder, the background image doesn't show up. UIBarButtonItem *resetButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Reset" style:UIBarButtonItemStylePlain target:self action:@selector(resetCriteria:)]; UIImage *img = [UIImage imageNamed:@"someImage.png"]; img = [img stretchableImageWithLeftCapWidth:5 topCapHeight:20]; [resetButtonItem setBackgroundImage:img forState

Adding a Custom Button to a UINavigationItem LeftBarButtonItem

怎甘沉沦 提交于 2019-12-08 03:16:56
问题 Could anyone tell me why this code does not working? self.backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.backButton setImage:[UIImage imageNamed:@"back_arrow.png"] forState:UIControlStateNormal]; self.backButton.contentMode = UIViewContentModeCenter; [self.backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton]; [navigationItem

Changing vertical position of UIBarButtonItem on iOS 8.2

跟風遠走 提交于 2019-12-08 03:02:05
问题 Here is my navigation bar I had a problem about changing vertical position of Settings UIBarButtonItem on my navigation bar. I would like to move the button item "Settings" down Here is my code UIBarButtonItem *settingsItem = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStylePlain target:self action:nil]; self.navItem.rightBarButtonItem = settingsItem; [[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0,-10) forBarMetrics:UIBarMetricsDefault]; I

iOS - Changing UIBarButtonItem's height

非 Y 不嫁゛ 提交于 2019-12-08 02:39:52
问题 UIToolbar has a nice option for resizing (self.navigationController.toolbar.frame) I'm wondering if anyone knows of a way to change the height of a UIBarButtonItem? I have a custom toolbar with a height of 117 pixels and so far I haven't found a way of modifying the buttons on the toolbar. Also I need it to be a toolbar because the displayed view gets covered with another animated view (cut scene style) while I setup assets in the first view and the toolbar needs to stay on top during all of