Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It is Possible to set background image for a label

Tags:

swift

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?

like image 297
B.Saravana Kumar Avatar asked Oct 14 '15 10:10

B.Saravana Kumar


2 Answers

This should do the trick:

yourLabel.backgroundColor = UIColor(patternImage: UIImage(named: "backgroundImage")!)
like image 136
Dejan Skledar Avatar answered Sep 22 '22 12:09

Dejan Skledar


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

like image 38
Jayprakash Dubey Avatar answered Sep 22 '22 12:09

Jayprakash Dubey