Color Conversion Tool

Source: Internet
Author: User

Recently, I was developing objective-C and found that the parameters required to use uicolor in objective-C to generate colors are not the 0-255 and hexadecimal Representation Methods We generally use, it is a decimal representation of 0-1 (for example, uicolor * color = [uicolor colorwithred: 0.79 Green: 0.87 Blue: 0.91 ALPHA: 1, so I used flash to write a conversion tool for use by friends who needed it.

Resend two macros that take color in objective-C:

 //  RGB color macro  
# Define Uicolorfromrgb (rgbvalue) [uicolor \
Colorwithred :(( Float ) (Rgbvalue & 0xff0000 ) > 16 )) / 255.0 \
Green :(( Float ) (Rgbvalue & 0xff00 ) > 8 )) / 255.0 \
Blue :(( Float ) (Rgbvalue & 0xff )) / 255.0 ALPHA: 1.0 ]

// RGB color macro with alpha
# Define Uicolorfromrgbwithalpha (rgbvalue, A) [uicolor \
Colorwithred :(( Float ) (Rgbvalue & 0xff0000 ) > 16 )) / 255.0 \
Green :(( Float ) (Rgbvalue & 0xff00 ) > 8 )) / 255.0 \
Blue :(( Float ) (Rgbvalue & 0xff )) / 255.0 ALPHA: A]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.