How can I change UIButton title color?

How can I change UIButton title color?

Hi,

I have a button in my iPhone/iPad application. I want to change the color of the text when user clicks on it making it selected.

Provide me good example code.

Thanks

View Answers

January 2, 2011 at 2:30 PM

Hi,

You have to set the color of the button for a particular state say: forSelected.

Use the following code:

[myButtonsetTitleColor:[UIColor redColor] forState:UIControlStateNormal];

Thanks


January 2, 2011 at 2:31 PM

Hi,

There is space between myButton setTitleColor.

Here is corrected code:

[myButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

Thanks









Related Tutorials/Questions & Answers:
How can I change UIButton title color?
What is the default session time in php and how can I change it?
Advertisements
I want to change my user name on your website ,how can i do this
UIButton setTitle forState
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
Change panel height, width and title
How do I change a large string into hex and then into byte so that SHA1 can be applied to it?
ModuleNotFoundError: No module named 'colorp'
ModuleNotFoundError: No module named 'colory'
ModuleNotFoundError: No module named 'colorz'
ModuleNotFoundError: No module named 'colord'
ModuleNotFoundError: No module named 'colorr'
ModuleNotFoundError: No module named 'colorr'
UIButton Image Change
can i change the logo of the web site on the fly - JSP-Servlet
iPhone Change Button Text
How to print UIButton id
UIButton
How to send UIWebView Title to UINavigationBar
How can I do it? .click();
How can I learn Java?
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
how should i can solve
UIButton custom programmatically
specify colors
how to mark different colors for diffent rows - Java Beginners
UINavigationController how to set title
how can i display a pdf file in a jtextarea
how can i add hibernate plugin to eclipse?
how i can get jqfade.js library
how can i remove newline characters and tabs
how can i make monthly register ?
how can i display a editable result of form?
how can i create a discussion forum?
UIButton setTitle:forState:
How can I learn Java in 5 minutes
How can I to my database to my application
How can i modify my account in roseindia
How can I protect my database password ?
How can I master Java in one month?
how can i print the selected content of a frame
UIButton text color
How can i use Facebook connect button
how can i close a frame. - Java Beginners
How can I create sessionfactory in Hibernate?
How can I start big data?

Ads