我有一个名为Common.h
的文件,其中定义了以下内容:
// Get UIColor from Hex value
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define CellTextColor UIColorFromRGB((uint32_t) 0x217EB5)
我希望能够在Swift中使用
CellTextColor
进行着色。但是它不允许我运行宏。只有当我使用#define value @"string"
时,它才能在Swift中正常工作。这里还需要做些什么吗?
我阅读了以下链接:
- 如何在Swift中使用Objective-C代码和#define宏 - https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html