How to get RGB values from UIColor?

后端 未结 15 1611
孤城傲影
孤城傲影 2020-11-28 22:27

I\'m creating a color object using the following code.

curView.backgroundColor = [[UIColor alloc] initWithHue:229 saturation:40 brightness:75 alpha:1];
         


        
15条回答
  •  [愿得一人]
    2020-11-28 23:17

    Hopefully this will be helpful

    CGFloat red, green, blue, alpha;
    
    //Create a sample color
    
    UIColor *redColor = [UIColor redColor];
    
    //Call 
    
    [redColor getRed: &red 
      green: &green
      blue: &blue 
      alpha: &alpha];
    NSLog(@"red = %f. Green = %f. Blue = %f. Alpha = %f",
      red,
      green,
      blue,
      alpha);
    

提交回复
热议问题