Search code examples
iosswiftbuttoncellrgb

Swift custom rgb color not shown


So i use a custom color from https://www.rapidtables.com/convert/color/hex-to-rgb.html for button title in cell. But somehow some colors are not set like the silver color RGB((192,192,192), it just show white color for the cell button label.

I set button title color using the following syntax:

cell.viewAllButton.setTitleColor(UIColor(red: 192, green: 192, blue: 192, alpha: 1.0), for: .normal)

For other colors, it set the button label successfully.


Solution

  • It should work

    cell.viewAllButton.setTitleColor(UIColor(red: 192/255, green: 192/255, blue: 192/255, alpha: 1.0), for: .normal)