UIBarButtonItem with UIImage Always Tinted iOS 7

I spent an evening trying to figure this out as well. You were very close to the solution. The trick is to instantiate the UIImage with the rendering mode. Instead of doing: UIImage *image = [UIImage imageNamed:@”myImage.png”]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; do this: UIImage *image = [[UIImage imageNamed:@”myImage.png”] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; and it works! In my case, … Read more

add image to UIBarButtonItem using initWithImage:(UIImage *)image

And for iOS 7+ you do the following: Objective-C UIImage *image = [[UIImage imageNamed:@”myImage.png”] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(YOUR_METHOD:)]; Swift 2.3 let image = UIImage(named: “myImage”)?.imageWithRenderingMode(.AlwaysOriginal) let button = UIBarButtonItem(image: image, style: .Plain, target: self, action: #selector(YOUR_METHOD(_:))) Swift 3.0 let image = UIImage(named: “myImage”)?.withRenderingMode(.alwaysOriginal) let button = UIBarButtonItem(image: image, style: … Read more

Swift Custom NavBar Back Button Image and Text

You can do something like that: let yourBackImage = UIImage(named: “back_button_image”) self.navigationController?.navigationBar.backIndicatorImage = yourBackImage self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = yourBackImage self.navigationController?.navigationBar.backItem?.title = “Custom” Your image will only have one color though

Change position of UIBarButtonItem in UINavigationBar

This code creates a back button for UINavigationBar with image background and custom position. The trick is to create an intermediate view and modify its bounds. Swift 5 let menuBtn = UIButton(type: .custom) let backBtnImage = UIImage(named: “menu”) menuBtn.setBackgroundImage(backBtnImage, for: .normal) menuBtn.addTarget(self, action: #selector(showMenuTapped), for: .touchUpInside) menuBtn.frame = CGRect(x: 0, y: 0, width: 45, height: … Read more

How to set image for bar button with swift?

I have achieved that programatically with this code: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() //create a new button let button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton //set image for button button.setImage(UIImage(named: “fb.png”), forState: UIControlState.Normal) //add function for button button.addTarget(self, action: “fbButtonPressed”, forControlEvents: UIControlEvents.TouchUpInside) //set frame button.frame = CGRectMake(0, 0, 53, 31) … Read more

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

Works until iOS11! You can use negative flexible spaces and rightBarButtonItems property instead of rightBarButtonItem: UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; spacer.width = -10; // for example shift right bar button to the right self.navigationItem.rightBarButtonItems = @[spacer, yourBarButton];

How to add multiple UIBarButtonItems on right side of Navigation Bar?

Use this in swift: override func viewDidLoad() { super.viewDidLoad() let editImage = UIImage(named: “plus”)! let searchImage = UIImage(named: “search”)! let editButton = UIBarButtonItem(image: editImage, style: .Plain, target: self, action: “didTapEditButton:”) let searchButton = UIBarButtonItem(image: searchImage, style: .Plain, target: self, action: “didTapSearchButton:”) navigationItem.rightBarButtonItems = [editButton, searchButton] } Write the action functions like this: func didTapEditButton(sender: AnyObject){ … Read more

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