UIBarButtonItem changes its tintColor immediately on touchDown, but UIButton seems to wait for longPress before showing it's highlighted color...
What is the correct way to change a button's highlight color immediately on touchDown?
Related
I am using the AVPlayerViewController to play video. To change the background color of buttons' controls background view as highlighted in below screenshot:-
When I tried to change the color as:-
self.contentOverlayView?.backgroundColor = UIColor.brown
then the whole view's color get changes as below:-
How to change the color of top and bottom controls' background view.
Now,when I clicked backbutton,the alpha of leftbarbutton item changed.
But I don't want to change alpha of leftbarbutton's arrow when I clicked backbutton.
I uploaded picture which alpha is changed when i clicked back button.
How can i realize?
Initialise the UIBarButtonItem with a UIButton as its custom view, and set the the button's adjustsImageWhenHighlighted property to false.
I have a UIView, holding a UIButton, set as my navigationItem.titleView. When I update the text for this button, it briefly blinks (disappearing and reappearing with the new text.)
Is there anyway to keep it visible when it's changed? So, if I change 2015-2016 it appears as if only the last digit is updated to 6?
Thanks
I solved my problem. This has more to do with UIButton than anything in the navigationBar's titleView.
If a UIButton is set as [yourButton buttonWithType:UIButtonTypeCustom], then it will not blink when it has been updated with [yourButton setTitle:#"title" forState:UIControlStateNormal];
I know my case may be rare but how do you disable the UIButton tint colour in this case?
I have a customised UIButton which has attributedTitle to help display the button pattern in different colour and alpha.
In my customised button .m file I have set something like this
[self setBackgroundImage:[self imageWithColor:[UIColor grayColor]] forState:UIControlStateSelected];
which will make the background colour to gray when the button is selected
However the real result looks like this:
Some how the text colour gets turned into white which I think is because of the tint effect on UIButtons.
Is that possible for me to have the background as grey while the text still remain the colour as set in the attributed title on selected state of the button?
Thanks
yourbutton = [UIButton buttonWithType:UIButtonTypeCustom];
(or)
If u placed button in storyboard....Choose button type as custom instead of system.
You can override setImage:forState: in UIButton subclass and change rendering mode to .alwaysOriginal.
override func setImage(_ image: UIImage?, for state: UIControlState) {
let newImage = image?.withRenderingMode(.alwaysOriginal)
super.setImage(newImage, for: state)
}
Simple, just head to the image in your assets, and set its rendering mode to "Original Image", check image below:
Follow this steps to get result:
First set UITabBar background color to clear
Now put this line in viewDidLoad method of the first page:
[[UITabBar appearance] setTintColor:SETYOURCOLOR];
Hope it will help you.
I have a set of buttons on a view controller that are added to the .xib and their properties are adjusted programmatically.
The background color is set in code as follows and then when it is tapped I change the background color using a selector method.
in configureButtons method:
[btn addTarget:self action:#selector(changeButtonBackGroundColor:) forControlEvents:UIControlEventTouchDown];
which calls the following:
-(void) changeButtonBackGroundColor:(id) sender {
[sender setBackgroundColor:[UIColor colorWithRed: 199/255. green: 95/255. blue: 45/255. alpha:1.0]];
}
Adjusting the background when touched programmatically works fine when the "Highlight Adjusts Image" property is set to YES but it shows the white glow when touched as well as changing the background color.
I don't want to see the white highlight when the button is touched so I turned off the property. This causes the background color change to stop working.
Is there a way to change the background color of a UIButton without also showing the white glowing highlight when touched?
You can try using background images with particular color. In that case you can easily make use of – setBackgroundImage:forState: function. I think this will work even when showsTouchWhenHighlighted is set to NO.