'Button added to navigation Item always shows in blue colour
created UIBarButtonItem added Power Image to it.
barBtnPower = new UIBarButtonItem (UIImage.FromBundle ("Images/[email protected]")
, UIBarButtonItemStyle.Plain
, (sender, args) => {
});
button added to navigation Item on right side.
this.NavigationItem.SetRightBarButtonItem (barBtn_Logout, true);
Issue is [email protected] is in green colour. but after run the application its shows in blue.
Can any one advice what i have done wrong here.
Solution 1:[1]
Use the always original rendering mode, if you don't want the navigation bar's tintColor property to effect your button's color.
barBtnPower = new UIBarButtonItem (UIImage.FromBundle("Images/[email protected]").imageWithRenderingMode(.AlwaysOriginal)
, UIBarButtonItemStyle.Plain
, (sender, args) => {});
Solution 2:[2]
Updated answer with Swift 5
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "roulette")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(buttonRouletteClicked))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dávid Kaszás |
| Solution 2 | shahil |
