B.Saravana Kumar
B.Saravana Kumar

Reputation: 1242

It is Possible to set background image for a label

I want to set background image for a label in my project but i dont know for how to set, please say it is possible or not?

Upvotes: 6

Views: 13369

Answers (2)

Jayprakash Dubey
Jayprakash Dubey

Reputation: 36447

The UILabel control does not have background image or image property.

You can set image to UILabel using backgroundColor property as shown below :

cell.lblNumber!.text = ""  
cell.lblNumber!.backgroundColor = UIColor(patternImage: UIImage(named: "OK")!)

Set the text to empty since it will display image and text on top of it.

Screenshot for solution

Upvotes: 3

Dejan Skledar
Dejan Skledar

Reputation: 11435

This should do the trick:

yourLabel.backgroundColor = UIColor(patternImage: UIImage(named: "backgroundImage")!)

Upvotes: 18

Related Questions