Reputation: 1667
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
Upvotes: 20
Views: 16280
Reputation: 578
Simple, just head to the image in your assets, and set its rendering mode to "Original Image", check image below:
Upvotes: 5
Reputation: 10185
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)
}
Upvotes: 15
Reputation: 1783
Follow this steps to get result:
UITabBar
background color to clearNow put this line in viewDidLoad method of the first page:
[[UITabBar appearance] setTintColor:SETYOURCOLOR];
Hope it will help you.
Upvotes: -2
Reputation: 981
yourbutton = [UIButton buttonWithType:UIButtonTypeCustom];
(or)
If u placed button in storyboard....Choose button type as custom instead of system.
Upvotes: 47