Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8142915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:57:11+00:00 2026-06-06T12:57:11+00:00

Is there a quicker (or better) way to get the [RGBA] color components from

  • 0

Is there a quicker (or better) way to get the [RGBA] color components from UIColor? There seem to be a lot of variations of this around (some on here, all essentially similar to what I have done here) I am just curious if there is an alternative as it seems a bit “lacking” given that everything else is usually so complete and well thought out.

if([eachKey isEqualToString:@"NSColor"]) {
    UIColor *newColor = [attrs valueForKey:eachKey];
    //NSLog(@"COLOR: %@", newColor);
    CGColorRef colorRef = [newColor CGColor];
    //NSLog(@"%@", colorRef);
    int numComponets = CGColorGetNumberOfComponents(colorRef);
    if(numComponets == 4) {
        const CGFloat *components = CGColorGetComponents(colorRef);
        CGFloat compR = components[0];
        CGFloat compG = components[1];
        CGFloat compB = components[2];
        CGFloat compA = components[3];

        //NSLog(@"R:%f G:%f B:%f, A:%f", compR, compG, compB, compA);
    }
}

I am not looking for how (I think I have the long version above) I would just like to know if this is the way your supposed to do this now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:57:12+00:00Added an answer on June 6, 2026 at 12:57 pm
    CGFloat r, g, b, a;    
    [MyColor getRed: &r green:&g blue:&b alpha:&a];
    

    iOS 5+ required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a better way to do this function? Even though i'm doing the
I wonder if there is a quicker way for this: I have my Management
Is there a better way of doing this... MyString.Trim().Replace(&, and).Replace(,, ).Replace( , ) .Replace(
Is there anyway to get the alt tag to display quicker? Also, I notice
Is there a way to extract all items from a single column in a
Does anyone know if there is a quicker way of editing a record that
All, I would like to know if there is a better way of getting
I have been trying to find out if there is a better way to
Is there a quicker way to convert the following data into a c style
There is a column that exists in 2 tables. In table 1, this column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.