uibarbuttonitem

Change color of Back button in navigation bar

孤人 提交于 2019-11-28 02:58:11
I am trying to change the color of the Settings button to white, but can't get it to change. I've tried both of these: navigationItem.leftBarButtonItem?.tintColor = UIColor.whiteColor() navigationItem.backBarButtonItem?.tintColor = UIColor.whiteColor() but no change, it still looks like this: How do I make that button white? Etgar You can change the global tint color in your storyboard by clicking on an empty space on the board and select in the right toolbar "Show the file inspector", and you will see in the bottom of the toolbar the "Global Tint" option. Chamath Jeevan This code changes the

Change the font of a UIBarButtonItem

帅比萌擦擦* 提交于 2019-11-28 02:54:30
I have a UIBarButtonItem in my UIToolbar titled Done . Now I want to change the font from the default to "Trebuchet MS" with Bold. How can I do that? teriiehina Because UIBarButtonItem inherits from UIBarItem, you can try - (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state but this is for iOS5 only. For iOS 3/4, you will have to use a custom view. mask To be precise, this can be done as below [buttonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"Helvetica-Bold" size:26.0], NSFontAttributeName, [UIColor

How can I set size leftBarButtonItem?

≡放荡痞女 提交于 2019-11-28 01:32:44
I am trying set size programmatically of left button bar item but i can't it. This is my code: let backButton = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) backButton.setBackgroundImage(UIImage(named: "hipster_pelo2.png"), for: .normal) self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton) But this is the result in iphone X with Xcode 9 and swift 3. In the image, you can see title app move it to the right because button size: Anybody know that the problem will be the image size?? You can restrict the size of barButton items using let barButton =

Get the frame of UIBarButtonItem in Swift?

梦想与她 提交于 2019-11-27 23:33:22
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 Christian Wörz You should try it like: var barButtonItem = self.navigationItem.rightBarButtonItem! var buttonItemView = barButtonItem

UIBarButtonItem not clickable on iOS 11 beta 7?

三世轮回 提交于 2019-11-27 23:25:44
问题 There is another question on SO about this but this has nothing to do with it because I think this has to do with a beta version of iOS 11. I have these 2 UIButton s that are grouped inside a UIView . This UIView is put inside a UIBarButtonItem and the whole thing is set as Left Bar Button Items , using Interface Builder. Each button, when clicked, show a popover, triggered by storyboard. I am testing this on an iPad 3, running iOS 9, using Xcode 8. This works wonderfully. Now I have decided

How to handle UINavigationControllers and UITabBarControllers iOS 6.1

谁说我不能喝 提交于 2019-11-27 23:24:26
I need a good explanation how can I handle the UINavigationControllers and the UITabBarControllers on iOS6.1 with StoryBoards. When I load my app (1st ViewController) I need if (FB login = success) it jumps with segues to the 2nd ViewController automatically. Here I think I can't use a UINavigationController like root, apple's HIG don't like it. I need a UITabBarController that connects to 3 UICollectionViewControllers (one tab for each one). I have to put the UITabBarController like root? If yes, how can I handle the others Viewontrollers between them? Like this: I need a custom BarButtonItem

programmatically highlight UIBarButtonItem

帅比萌擦擦* 提交于 2019-11-27 22:05:40
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. setSelected and setHighlighted work fine on UIControls, but not UIBarButtonItems (which are not UIControls). I'd recommend using UIBarButtonItem's - (void)setBackgroundImage:(UIImage *)backgroundImage forState:

UIBarButtonItem Custom view in UINavigationBar

南楼画角 提交于 2019-11-27 22:03:58
I am making a custom bar buttons for uinavigationbar, I am using following code UIImageView *backImgView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chk_back.png"]]; [backImgView setUserInteractionEnabled:YES]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:backImgView]; [backButton setTarget:self]; [backButton setAction:@selector(BackBtn)]; checkIn_NavBar.topItem.leftBarButtonItem = backButton; The problem is it is not calling its action. What i am doing wrong? 来源: https://stackoverflow.com/questions/16057567/uibarbuttonitem-custom-view-in

Change width of a UIBarButtonItem in a UINavigationBar

主宰稳场 提交于 2019-11-27 21:16:52
I am creating a UIBarButtonItem and adding it to my navigation bar like so: (void)viewDidLoad { ... // Add the refresh button to the navigation bar UIButton *refreshButton = [UIButton buttonWithType:UIButtonTypeCustom]; [refreshButton setFrame:CGRectMake(0,0,30,30)]; [refreshButton setImage:[UIImage imageNamed:@"G_refresh_icon.png"] forState:UIControlStateNormal]; [refreshButton addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *refreshBarButton = [[[UIBarButtonItem alloc] initWithCustomView:refreshButton] autorelease]; self

Get the width of a UIBarButtonItem

杀马特。学长 韩版系。学妹 提交于 2019-11-27 19:28:52
I'm trying to get the width of a UIBarButtonItem . This doesn't work: barbuttonitem.customView.frame.size.width And this won't work, either: barbuttonitem.width What about this: UIBarButtonItem *item = /*...*/; UIView *view = [item valueForKey:@"view"]; CGFloat width = view? [view frame].size.width : (CGFloat)0.0; I had the same problem. After a lot of tries I found something that worked! In my specific case, I needed to get the width of the first UIBarButtonItem from the navigation controller's toolbar, but you can easily adapt it to your likings: UIToolbar *toolbar = self