在定义全局颜色宏的时候,为了整齐把空格删了,写在了同一行里,调用的时候,出错提示“Expected identifier”,如下:

Object_C 定义全局宏的颜色时,报“Expected identifier”的错误

如果宏定义如上那样的话,在调用的时候,会出现如下的问题:

Object_C 定义全局宏的颜色时,报“Expected identifier”的错误

百思不得解,而正确的定义颜色宏的格式如下:

Object_C 定义全局宏的颜色时,报“Expected identifier”的错误

代码如下:

#define UIColorFromHEXWithAlpha(rgbValue,a) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]

 

相关文章:

  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-04-30
  • 2021-04-03
  • 2022-12-23
  • 2021-04-19
  • 2021-06-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
相关资源
相似解决方案