Search code examples
iosswiftuibuttonuibackgroundcolor

change the background color of the title in UIButton


I would like to change the background color of the title (only!) in UIButton, which contains title and image.

I can only see how to change to background color of the whole button, which is not what I want.

Any idea ?


Solution

  • The full answer is :

     btn.tintColor = UIColor.clear  //if we have different tint, which I had 
     btn.titleLabel?.backgroundColor = UIColor.clear