设置.xib发射图像背景的背景颜色

时间:2015-06-22 20:10:41

标签: objective-c

我需要一个特定的十六进制代码作为背景颜色,而不是从预先选择的列表中删除。我该如何做到这一点?

1 个答案:

答案 0 :(得分:1)

对于启动.xib,您无法以编程方式更改颜色。您可以在侧边菜单中输入十六进制值。单击背景颜色,从左侧选择第二个对象,您可以输入十六进制值和RGB值。

如果您想在整个应用中使用颜色(当您可以通过编程方式执行操作时),请使用颜色十六进制website将颜色转换为RGB值。

如果您有特定且一致的颜色需求,我建议您创建自定义类别来存储自定义颜色。答案示例为here

<强>的UIColor + CustomColorCatagory.h

 #import <UIKit/UIKit.h>

@interface UIColor (CustomColorCatagory)   //This line is one of the most important ones - it tells the complier your extending the normal set of methods on UIColor
+ (UIColor *)customColor;

@end

<强>的UIColor + CustomColorCatagory.m

#import "UIColor+CustomColorCatagory.h"

@implementation UIColor (CustomColorCatagory)
+ (UIColor *)customColor {
    return [UIColor colorWithRed:0.643 green:0.643 blue:0.643 alpha:1];
}
@end

希望这有帮助!

相关问题