Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing color of button text and state

Tags:

I need to change the color of my button's text. I also need to change the state to Disabled after the user presses it.

I have no idea how to do this. I've been looking things up for a while but they're all either in objective C or I can't understand it (usually help docs, they're stupid.).

like image 446
Rising Avatar asked Aug 06 '14 21:08

Rising


People also ask

How do I change the color of my text buttons?

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=".

How do I change the button text color in react native?

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.


1 Answers

In swift you change color for a specific State with the setTitleColor method.

In you case it will be :

button.setTitleColor(UIColor.grayColor, forState: UIControlState.Normal) 

Swift 5 Update:

button.setTitleColor(UIColor.grayColor, for: UIControl.State.normal) 
like image 142
Paradisiak Avatar answered Sep 28 '22 02:09

Paradisiak