0

I want to add a gradient color to my UILabel or any text on my iPhone screen. I want to know the ways to do it. Both Using interface and programatically.

tnx

rkb
  • 10,933
  • 22
  • 76
  • 103
  • This is very similar to this question: http://stackoverflow.com/questions/1266179/how-to-add-a-gradient-on-a-uilabel – Brad Larson Aug 12 '09 at 16:49

2 Answers2

0

EDIT:

I expanded on my previous comment after all and created a little subclass of UILabel for this purpose. You can read about it here where you can also get the code.

This is the result:

enter image description here

Old reply:

Please see my reply to this question: How do I add a gradient to the text of a UILabel, but not the background?

Shows the code needed to achieve what you are after.

Community
  • 1
  • 1
Dimitris
  • 13,480
  • 17
  • 74
  • 94
-1

In in the interface, you should be able to select the label and go to inspector (apple + 1) and change the color from there.

Programmatically, use the following property.

UILabel textColor property reference

Example:

[mylabel setTextColor: [UIColor redColor]];

UIColor reference.

To gradient, all you have to do is extend this a little. Break the text that you want to gradient into a group of labels, group them with a list of some sort, and iterate over the grouped labels and apply a textColor. This sort of gradient is trivial and derives immediately from the documentation provided.

Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406