UIColor saturation brightness values different from the regular saturation luminosity values of a color

UIColor saturation brightness values different from the regular saturation luminosity values of a color

By : K. Smith
Date : November 21 2020, 03:00 PM
it fixes the issue A few things are going on here.
First, HSB == HSV, as discussed in this post.
code :

Share : facebook icon twitter icon
Is there function to convert UIColor to Hue Saturation Brightness?

Is there function to convert UIColor to Hue Saturation Brightness?

By : dreid96
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Use the UIColor method: getHue:saturation:brightness:alpha:
From the Apple docs:
code :
- (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha
UIColor *testColor = [UIColor colorWithRed:0.53 green:0.37 blue:0.11 alpha:1.00];

CGFloat hue;
CGFloat saturation;
CGFloat brightness;
CGFloat alpha;
BOOL success = [testColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
NSLog(@"success: %i hue: %0.2f, saturation: %0.2f, brightness: %0.2f, alpha: %0.2f", success, hue, saturation, brightness, alpha);
// Test values
CGFloat red = 0.53;
CGFloat green = 0.37;
CGFloat blue = 0.11;

CGFloat hue = 0;
CGFloat saturation = 0;
CGFloat brightness = 0;

CGFloat minRGB = MIN(red, MIN(green,blue));
CGFloat maxRGB = MAX(red, MAX(green,blue));

if (minRGB==maxRGB) {
    hue = 0;
    saturation = 0;
    brightness = minRGB;
} else {
    CGFloat d = (red==minRGB) ? green-blue : ((blue==minRGB) ? red-green : blue-red);
    CGFloat h = (red==minRGB) ? 3 : ((blue==minRGB) ? 1 : 5);
    hue = (h - d/(maxRGB - minRGB)) / 6.0;
    saturation = (maxRGB - minRGB)/maxRGB;
    brightness = maxRGB;
NSLog(@"hue: %0.2f, saturation: %0.2f, value: %0.2f", hue, saturation, brightness);
How can I modify a UIColor's hue, brightness and saturation?

How can I modify a UIColor's hue, brightness and saturation?

By : Zhao Kang
Date : March 29 2020, 07:55 AM
around this issue You can call getHue:saturation:brightness:alpha: on your color, then adjust the values, then create a new color with your adjusted components using +[UIColor colorWithHue:saturation:brightness:alpha:]
code :
CGFloat hue, saturation, brightness, alpha ;
BOOL ok = [ <color> getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha ] ;
if ( !ok ) { 
    // handle error 
// ... adjust components..

UIColor * newColor = [ UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha ] ;
WebGL: Change color saturation or luminosity in fragment shader

WebGL: Change color saturation or luminosity in fragment shader

By : Sérgio
Date : March 29 2020, 07:55 AM
To fix the issue you can do thanks for geat links but i think that i found much simplier way to made easy color transition, all i need is to use webGL method T mix(T x, T y, float a) - linear blend of x and y.
This code i use in shadertoy editor:
code :
void mainImage( out vec4 fragColor, in vec2 fragCoord )
     vec2 uv = gl_FragCoord.xy / iResolution.xy;
     vec4 orange = vec4(0.533, 0.25, 0.145, 1.0);
     vec4 blue = vec4(0.18, 0.23, 0.27, 1.0);
     vec4 black = vec4(0.0, 0.0, 0.0, 1.0);
     vec4 white = vec4(1.0, 1.0, 1.0, 1.0);

     float ratio = iResolution.x / iResolution.y;
     float PI = 3.14159265359;

     vec4 mixC = mix(orange, blue, sin(ratio * uv.y));
     mixC = mix(mixC, black, cos(2.0 * PI * uv.x) / ratio);
     mixC = mix(mixC, black, cos(2.0 * PI * uv.y) / ratio);
     mixC = mix(mixC, white, 0.1);
     fragColor = mixC;   
UIColor getHue:saturation:brightness:alpha: returns NO

UIColor getHue:saturation:brightness:alpha: returns NO

By : JSerra1
Date : March 29 2020, 07:55 AM
help you fix your problem It appears that the UIColor getHue:saturation:brightness: method doesn't work if the color's color space is sRGB but it does work if the color's color space is Extended sRGB.
So the solution is to update the selected Color Space for each of your colors in your color set asset.
code :
if let cs = CGColorSpace(name: CGColorSpace.sRGB) {
    if let cc = CGColor(colorSpace: cs, components: [0.5, 0.7, 0.3, 1.0]) {
        let color = UIColor(cgColor: cc)
        var h: CGFloat = 0
        var s: CGFloat = 0
        var b: CGFloat = 0
        if color.getHue(&h, saturation: &s, brightness: &b, alpha: nil) {
            print(h, s, b)
        } else {
            print("Failed with color space \(cs)")
How do i get the hue, saturation and brightness from a UIColor?

How do i get the hue, saturation and brightness from a UIColor?

By : Wafa Fatima
Date : March 29 2020, 07:55 AM
I wish this helpful for you I want to get the individual values from a UIColor. Unsure how to do it?
Related Posts Related Posts :
  • Apartment number / Unit number returned from google places api
  • How to align UICollectionViewCells from left to right?
  • How can I add search option on UIPickerview in ios?
  • Scenekit - physicsWorld setup to prevent kinematic nodes to intersect
  • Carthage Build Failed
  • swift 3, ios 10 - push notification firebase is not received
  • App Xcode 8 to Xcode 9 - Prevent Auto Hide Status Bar
  • How to pop back to a TableViewController?
  • Is UserDefaults thread safe in Swift? How to check it?
  • UISwitch in a table selects multiple cells when switch state on
  • iOS App with no story board (Size classes and Device type limitations)
  • AudioKit issue, mic not sensitive enough
  • send indexpath to Firebase (like button)
  • JSON: Extracting Data Using Alamofire and Swift 3
  • invalid_grant on OAuth2 request when obtaining access_token from SSO in App
  • ABNewPersonViewController using contact framework
  • Design iOS button scalable
  • Subclassing NSLayoutConstraint constant based on screen height
  • Migrate Realm 2.x List of Object to Realm 3.x List of String (or other primary type)
  • Using BLE RSSI value for connect-by-proximity
  • Backgroundcolor of NSTextfield
  • Firebase modifying uid in every view
  • How to rotate orientation?
  • Upload a new version of ios app to app store?
  • UIScrollView do not scroll down to its original position when keyboard disappear
  • What is the most effective way of tracking time/dates in an iOS/Swift application?
  • WatchKit get user's preferred handedness
  • Location permission dialog is shown and immediately disappears
  • Combine these regex expressions
  • How to save an array of HKQuantitySamples (heart rate) to a workout
  • RestKit mapping with parent key as attribute and key contains parenthesis
  • How to add UITextField programmatically to UIScrollView without breaking constraints?
  • How to make a view height grow depending on its child views contents
  • Some users experiencing NSInternalInconsistencyException crash
  • Mark successful siesta response as error
  • Using a modified PDFTron Tools Framework
  • How can I use universal links when I call openURL inside my own app?
  • NSArray of doubles iOS (Objective c)
  • Passing data from embedded PageViewController to parent View Controller
  • Reuse item inside a row when scrolling
  • Realm Relation how to implement
  • error: generic parameter 'T' could not be inferred in swift
  • Adding shadow to UITextView makes text expand out of UITextViewFrame
  • How to change the string in seconds to minutes in Swift3?
  • Search bar is refreshing the index of my table view cell
  • Decodable multiple DateDecodingStrategies
  • The spoiled simulator xcode 9. As a broken TV
  • How to set width of TouchableWithoutFeedback depends on Text in react-native?
  • How to show an UIActivityIndicatorView whitin UITableViewController?
  • UItextfield text in Custom UITableViewCell prints nil when i scroll up in SE
  • How to append or add multiple items to an array in Swift 4
  • SQLite WHERE column MATCH parameter binding
  • Load iframe tag (video) from html string into web view using Swift 3
  • How to determine when a custom UICollectionViewCell is 100% on the screen
  • Get safe area inset top and bottom heights
  • Cordova iOS project: xCode 9 missing some entitlements
  • UITableView not scrolling properly to bottom until a cell is clicked
  • Reloading Particular Row of PickerView in swift
  • How to present a ViewController after pressing a button inside of a CollectionViewCell
  • filtering array of custom view controllers for property?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org