iphone - [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1]的MACRO函数RGBCOLOR(R,G,B)是什么?

标签 iphone ios objective-c ipad uicolor

我只想使用MACRO函数RGBCOLOR(R,G,B)重写颜色常量值

我的代码是:

#define kBasketEditedQuantityBorderColor  [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1]

最佳答案

您可以直接在Objective-C中使用C宏函数

#define RGBCOLOR(r, g, b) [UIColor colorWithRed:r/225.0f green:g/225.0f blue:b/225.0f alpha:1]

RGBCOLOR(25.0f, 25.0f, 114.0f) 

希望这能达成您的目标。

例如:
[yourView setBackgroundColor:RGBCOLOR(25.0f,25.0f,114.0f)];

http://www.codeproject.com/Articles/8376/Function-like-Macros-vs-Inline-Functions

关于iphone - [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1]的MACRO函数RGBCOLOR(R,G,B)是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17858477/

相关文章:

ios - 在 UITableView 上添加 subview

iphone - __dyld_dyld 应用程序启动时出现 fatal error

ios - 通过 UIWebView 下载 PDF

iphone - 如何创建可以在软件中动态着色的艺术资源?

iphone - 从堆栈加载 UIViewController

ios - 任何将应用程序置于后台并在 Appium iOS 中重新启动的方法

ios - 没有冲突类别方法的警告

ios - setTranslation :inView: 中的速度问题

iOS 如何将 View 添加到键盘

iphone - NSMutableArray 到 NSString 的转换提供数组而不是字符串