lifemoveson
lifemoveson

Reputation: 1691

How can I set a cell on the iPhone as a custom color?

I am trying to add custom color like how we do in HTML:

<body bgcolor=#ffffff> </body>. 

Can we have a similar kind of custom color combination for showing in cells on iPhones?

cell.backgroundColor = [ UIColor whiteColor]; but instead of whiteColor wanna use #ffffff.

How can I implement this?

Upvotes: 0

Views: 500

Answers (1)

progrmr
progrmr

Reputation: 77201

Use UIColor colorWithRed:green:blue:alpha:. Colors are 0.0 to 1.0, something like this for bright red:

cell.backgroundColor = [UIColor colorWithRed:1.0f green:0 blue:0 alpha1];

For a color such as "808182" it would be:

[UIColor colorWithRed:128/255.0f green:129/255.0f blue:130/255.0f alpha:1];

Upvotes: 1

Related Questions