Button added to navigation Item always shows in blue colour
Asked Answered
L

2

7

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.

Lysander answered 29/9, 2014 at 5:41 Comment(1)
There is nothing wrong. Probably that navigationBar tintColor is blue. You can change that by using setTintColor: method of navigationBarResentment
I
7

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) => {});
Isadoraisadore answered 29/9, 2014 at 11:31 Comment(0)
D
2

Updated answer with Swift 5

self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "roulette")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(buttonRouletteClicked))
Deyo answered 11/4, 2022 at 10:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.