hex color from uicolor

前端 未结 4 1079
梦毁少年i
梦毁少年i 2021-01-04 08:56

i have a problem in converting uicolor to hex color, here what i found

CGColorRef colorref = [[Colorview_ backgroundColor] CGColor];

int numComponents = CG         


        
4条回答
  •  鱼传尺愫
    2021-01-04 09:42

    NSString *hexString = [NSString stringWithFormat:@"#%d", hexValue];
    

    You are formatting it as a digit with %d

    You want to format it as hex with %x or %X -- maybe as string %s I didnt check what the function is doing and what int hexValue is holding

    d or i Signed decimal integer 392

    x Unsigned hexadecimal integer 7fa

    X Unsigned hexadecimal integer (capital letters) 7FA

提交回复
热议问题