How to create fixed space and flexible space bar button items programmatically?

UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; fixedItem.width = 20.0f; // or whatever you want UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

Change the font of a UIBarButtonItem

To be precise, this can be done as below [buttonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@”Helvetica-Bold” size:26.0], NSFontAttributeName, [UIColor greenColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal]; Or with object literal syntax: [buttonItem setTitleTextAttributes:@{ NSFontAttributeName: [UIFont fontWithName:@”Helvetica-Bold” size:26.0], NSForegroundColorAttributeName: [UIColor greenColor] } forState:UIControlStateNormal]; For convenience, here’s the Swift implementation: buttonItem.setTitleTextAttributes([ NSAttributedStringKey.font: UIFont(name: “Helvetica-Bold”, size: 26.0)!, NSAttributedStringKey.foregroundColor: UIColor.green], for: .normal)

UIBarButtonItem in navigation bar programmatically?

Custom button image without setting button frame: You can use init(image: UIImage?, style: UIBarButtonItemStyle, target: Any?, action: Selector?) to initializes a new item using the specified image and other properties. let button1 = UIBarButtonItem(image: UIImage(named: “imagename”), style: .plain, target: self, action: Selector(“action”)) // action:#selector(Class.MethodName) for swift 3 self.navigationItem.rightBarButtonItem = button1 Check this Apple Doc. reference … Read more

Setting action for back button in navigation controller

Try putting this into the view controller where you want to detect the press: -(void) viewWillDisappear:(BOOL)animated { if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) { // back button was pressed. We know this is true because self is no longer // in the navigation stack. } [super viewWillDisappear:animated]; }

Removing the title text of an iOS UIBarButtonItem

To set the back button title for a view controller without changing its title use: Objective-C: self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@”” style:self.navigationItem.backBarButtonItem.style target:nil action:nil]; Swift: navigationItem.backBarButtonItem = UIBarButtonItem(title: “”, style: .plain, target: nil, action: nil) To be clear, this is done on the view controller that you would see if you hit the back button. … Read more

How do I show/hide a UIBarButtonItem?

Save your button in a strong outlet (let’s call it myButton) and do this to add/remove it: // Get the reference to the current toolbar buttons NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy]; // This is how you remove the button from the toolbar and animate it [toolbarButtons removeObject:self.myButton]; [self setToolbarItems:toolbarButtons animated:YES]; // This is how you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)