I have a custom button and I am setting the different image when it is highlighted. Now, I want to change the color of the text on the button when button is highlighted. Is it possible to do this?
Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".
You can use a Button from react-native like this and can also pass the color prop. For complex and custom buttons you can create it by your own styles using Touchables which are given by react-native you don't have to use any third-party libraries for that. The first code doesn't change the text colour.
To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color. HTML5 do not support the <font> tag, so the CSS style is used to add font color.
You can do it this way:
[myButton setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
Swift version:
myButton.setTitleColor(UIColor.greenColor(), forState: UIControlState.Highlighted)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With