uibarbuttonitem

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

假如想象 提交于 2019-12-30 09:57:13
问题 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"]

UIBarButtonItem with UIButton as CustomView - from UIButton, how to access the UIBarButtonItem its in?

佐手、 提交于 2019-12-30 06:24:24
问题 I have a UIBarButtonItem with UIButton as custom view. The UIButton has a addTarget:action: on it. In the action I present a popover. I'm currently presenting from the sender.frame (the UIButton 's Frame) I want to Present from the UIBarButtonItem instead. How can I access the UIBarButtonItem from the UIButton ? 回答1: If you have set your UIButton as the customView of a UIBarButtonItem , or a child of the custom view, then you can walk up the view hierarchy from your button until you find the

Customizing UIBarButtonItem “Done” style and “Plain” style separately using UIAppearance

岁酱吖の 提交于 2019-12-30 01:54:08
问题 I know how to customize UIBarButtonItem using -setBackgroundImage: forState: barMetrics: , but I would like to use different images for UIBarButtonItemStyleDone and UIBarButtonItemStylePlain . Is there a way to accomplish this using the UIAppearance protocol? Or do I have to set the image each time I want a "Done" style button? (I tried messing around with code like the following: [[UIBarButtonItem appearance] setBackgroundImage:image forState:UIControlStateNormal barMetrics

Programmatically segue from UIBarButtonItem

梦想的初衷 提交于 2019-12-29 08:48:14
问题 I have three view controllers, all with two buttons each on the right and left sides of the navigation bar, as seen below on one of them. I'm creating these buttons programatically, and instead of writing the code in each respective view controller (VC) I decided to write a Helper class that creates the buttons. // Note: I am using FontAwesome as a third-party library. class Helper: NSObject { static func loadNavBarItems(vc: UIViewController) { let profileButton = UIBarButtonItem() let

Setting action for back button in navigation controller

浪子不回头ぞ 提交于 2019-12-29 08:32:49
问题 I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the backbutton attribute it doesn't pay attention to them and it just pops the current view and goes back to the root: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Servers" style:UIBarButtonItemStylePlain target:self action:@selector(home)]; self.navigationItem.backBarButtonItem =

Setting action for back button in navigation controller

两盒软妹~` 提交于 2019-12-29 08:32:31
问题 I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the backbutton attribute it doesn't pay attention to them and it just pops the current view and goes back to the root: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Servers" style:UIBarButtonItemStylePlain target:self action:@selector(home)]; self.navigationItem.backBarButtonItem =

image for nav bar button item swift

限于喜欢 提交于 2019-12-29 04:12:11
问题 I want to display an image in the left hand side of my nav bar in swift. I have tried adding a nav bar button item and setting an image there. The problem is that I have to use a really small image for it to fit in the nav bar nicely. But making such a small image leads to pixelation especially on the bigger phone iPhone 6 and 6 Plus. Is there a way to use a good quality image and then set the frame to fit within the bounds of the nav bar? My attempt: var image = UIImage(named: "Harp.png")

UINavigationBar UIBarButtonItems much larger click area than required

房东的猫 提交于 2019-12-28 11:44:10
问题 hopefully someone can help me out- iv'e scoured the net for the answer and cannot find one- the UIBarButtonItems added to UINavigationBar have a much larger click area than required- for example, open up any project you have a nav bar with buttons on- click anywhere between the end of the button and the title of the nav bar- the button clicks, when you clearly did not click on the button- also try this- click underneath the nav bar, below the button, the button clicks for about 5+ pixels

Get the frame of UIBarButtonItem in Swift?

99封情书 提交于 2019-12-28 06:29:08
问题 how could I get the frame of a rightbarbuttonItem in swift? I found this : UIBarButtonItem: How can I find its frame? but it says cannot convert NSString to UIView, or cannot convert NSString to String : let str : NSString = "view" //or type String let theView : UIView = self.navigationItem.rightBarButtonItem!.valueForKey("view")//or 'str' The goal is to remove the rightBarButtonItem, add an imageView instead, and move it with a fadeOut effect. Thanks 回答1: You should try it like: var

programmatically highlight UIBarButtonItem

早过忘川 提交于 2019-12-28 05:59:07
问题 after tapping the 'record' BarButtonItem I would like to keep it programmatically highlighted until the recording is over. The highlighting graphics of iOS are very good, therefor I would like to remain or set that state. Up to now I found 'setSelected' and 'setHighlighted' but these do not work on a UIBarButtonItem. Any suggestions on how to solve this? Thank you in advance, Koen. 回答1: setSelected and setHighlighted work fine on UIControls, but not UIBarButtonItems (which are not UIControls)