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

  • Home
  • SEARCH
  • 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 6846407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:37:05+00:00 2026-05-27T00:37:05+00:00

There’s this method in UIColor in iOS 5: – (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat

  • 0

There’s this method in UIColor in iOS 5:

- (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha

But i don’t understand how i’m meant to use that in code. Surely i don’t need to be stating each of those components if i’m looking to get that out of the UIColor?

  • 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-05-27T00:37:07+00:00Added an answer on May 27, 2026 at 12:37 am
    CGFloat hue;
    CGFloat saturation;
    CGFloat brightness;
    CGFloat alpha;
    
    [aColor getHue:&hue 
        saturation:&saturation 
        brightness:&brightness 
             alpha:&alpha];    
    //now the variables hold the values
    

    getHue:saturation:brightness:alpha: returns a bool, determining, if the UIColor could had been converted at all.

    Example:

    BOOL b = [[UIColor colorWithRed:.23 green:.42 blue:.9 alpha:1.0] getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
    NSLog(@"%f %f %f %f %d", hue, saturation, brightness, alpha, b);
    

    will log 0.619403 0.744444 0.900000 1.000000 1, as it is valid

    while

    BOOL b = [[UIColor colorWithPatternImage:[UIImage imageNamed:@"pattern.png"]] getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
    NSLog(@"%f %f %f %f %d", hue, saturation, brightness, alpha, b);
    

    logs 0.000000 0.000000 -1.998918 0.000000 0. The last 0 is the Bool, so this is not valid, and actually brightness can only range from 0.0 to 1.0, but here it holds some random crap.

    Conclusion

    The code should be something like

    CGFloat hue;
    CGFloat saturation;
    CGFloat brightness;
    CGFloat alpha;
    
    if([aColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha]){
        //do what ever you want to do if values are valid
    } else {
        //what needs to be done, if converting failed? 
        //Some default values? raising an exception? return?
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There must be a simple solution to this, but after 4 hours of browsing
There are things like f.call(...) f.apply(...) But then there's this (1, alert)('Zomg what is
There is previous little on the google on this subject other than people asking
There was a smbmrx sample code using RDBSS in WDK Vista. But since WDK
There's no Sort() function for IList . Can someoene help me with this? I
There are many tutorials that talk about deleting index.php from the url. But I
There's a lot of reading on self referencing problems, but I can't seem to
There is a constant I'm using from the iOS SDK. I printed out the
There is this strange situation I'm fighting on. I have 3 pages, les call
There is this SQL Statement SELECT t1.Name ,Count(t2.SubID) Totals -- I don't know how

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.