how can i display voilet color in imageview
I need to display a image view that is filled with violet color picture as shown below
, but there us no UIColor 开发者_如何学Gocolor violet for this.How can i display it?
You can use:
[UIColor colorWithRed:0.5 green:0.0 blue:1 alpha:1.0]
to define a custom UIColor with values for red, green and blue, and set it to the background color of your ImageView:
imageView.backgroundColor = [UIColor colorWithRed:0.5 green:0.0 blue:1 alpha:1.0];
Take a look at this question regarding adding a border to the view.
EDIT (Question clarified somewhat)
It looks like you're trying to display an image that has a portion coloured at runtime.
To do this, create the image as a png, and leave the parts you want to be filled with the color transparent. You can then set the background color of the UIImageView to the violet approximation, and set the image property to the image you created.
Note that Violet is outside the color gamut of the RGB colour space, so you'll need to find the RGB values of the color you want. Also note this function takes values between 0 and 1 rather than 0 and 255.
My answer is same as Mr. Matt but the only problem with matts answer is as per MAHESHBABU it gives pink color. So now please try below code for your answer
imageView.backgroundColor = [UIColor colorWithRed:144.0/255.0 green:0.0/255.0 blue:255.0/255.0 alpha:1.0];
This is surely gonna give you correct color.
hAPPY cODING...
try this if earlier one not worked
something got wrong on my side,
imgView.backgroundColor = [UIColor colorWithRed:0.6 green:0.2 blue:1 alpha:1];
精彩评论