Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the color of a UIFont?

Tags:

ios

iphone

uifont

I've searched the web and I can't get a good answer, although I'm sure this is very simple. Can someone please show me how to do the following: Make a UIFont of name "Helvetica-Bold", size 8.0, and color of black.

I've got the name and size, but I can't figure out how to change the color:

UIFont *textFont = [UIFont fontWithName:@"Helvetica-Bold" size:8.0]; 

Thanks!

like image 353
CodeGuy Avatar asked Jan 03 '11 15:01

CodeGuy


1 Answers

UIFont does not contain/maintain any color information, so this is not possible. In general, controls that use UIFont such as a UILabel have both a font and a textColor property. So you would set a label's font and it's color like this:

myLabel.textColor = [UIColor blackColor]; myLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:8.0]; 
like image 65
theChrisKent Avatar answered Sep 25 '22 17:09

theChrisKent