I'm setting the tint color of a window to an arbitrary color, then trying to over-ride this on a per-button basis, but it appears that the buttons revert to the window tint color whenever there is a segue applied on them.
Setting tint color in didFinishLaunchingWithOptions:
self.window.tintColor = [UIColor redColor];
and then my two buttons in viewDidLoad:
[self.button1 setImage:[[UIImage imageNamed:#"711-trash"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
self.button1.tintColor = [UIColor purpleColor];
self.button2.tintColor = [UIColor blueColor];
where button1 is a custom type button and button2 is a system type button.
When the popover first presents, the two buttons are tinted purple and blue. But when the segue view controller is pushed, the popped, the two buttons switch to red. Is there any way to prevent this?
EDIT:
I've tried reproducing your code like this:
However everything worked as expected:
So I agree with #user3779315, possibly you are setting the buttons' tint color somewhere else. Btw, additional code of your project would help to clarify the issue :-)
Related
I'm having problems trying to figure out how to change the color of the buttons on the navigation controller.
Previously I had used the following:
[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:226/255.0 green:66/255.0 blue:66/255.0 alpha:0.0]];
and this worked, but I added a new view with a toolbar, and the tool bar button images will not show. If I remove the global coloring, the tool bar items show just fine.
I've tried setting the tint color on both the leftBarButtonItem and the backBarButtonItem in the viewDidLoad method of the view, but both of those properties appear to be null.
I don't want to change the color of the entire navigation bar, just the buttons. Is there a way to do this?
Yeah, I'll just post this as an answer. Your alpha is set to 0. So you're basically saying the same thing as [UIColor clearColor].
Not sure how that ever worked to give you a tint color on your bar button items.
In swift, it can be accomplished by the following command:
if let navController = self.navigationController
{
navController.navigationBar.tintColor = UIColor.whiteColor()
}
i want to change my application background change. My view name is topNavVw for change my application background color i used this code
topNavVw.backgroundColor = [UIColor blackColor];
but it's not working .
Thanks in advance
You have to call
self.view.backgroundColor = [UIColor blackColor];
in viewDidLoad, in the Controller class that you want to appear black.
If you want a specific view/button/label to have a black background then it is the same,
myView.backgroundColor = [UIColor blackColor];
If it still doesn't work, use the view hierarchy debug (the button just before the arrow on the bottom of the screen, in the separation of the debug screen and code screen). There you will be able to see all your views and maybe you'll notice that your black view is behind another view that is not black.
I have tab bar as shown in attached figure. I would like to make this blue color ,which I believe default, to green. Is there way to make it ?
You can use this at your view controller.
[[self tabBarController] tabBar].tintColor =[UIColor greenColor];
I am trying to find out how to change the text and arrow color of the UINavigationBar buttons.
I know how to change the titleTextAttributes but cannot find out how to do it to the buttons.
For example this is how I change the titleTextAttributes inside my AppDelegate
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName : [UIColor redColor]};
I have looked through the UINavigationBar docs and cannot find any button attributes so not sure what to do here.
to change the text color and the color of the arrow in the navigation bar you can use this code (iOS 7):
self.navigationController.navigationBar.tintColor = [UIColor redColor];
this code will also change the color of the buttons
You can globally change it as easy as this
I have a UINavigationBar with a pattern on it. I've seen a lot of UI that implement transparent UIBarButtonItem, and I wonder how to make the same.
Tint dosent do the trick unfortunately...
please help...
Put a UIButton inside the UIBarButton item. The button can be transparent. In Xcode's Interface Builder, just drag a UIButton to one of the empty corners of the UINavigationBar. Xcode will automatically create a UIBarButtonItem and put the UIButton inside it. You can then set the UIButton type to Custom and apply other properties such as title or image.
Follow the procedure described by Melsam and set the transparency of the button by using
button.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5];