【发布时间】:2014-10-18 12:59:34
【问题描述】:
我有这段代码应该修改连接到 IBoutletCollection 的 24 个按钮的颜色:
在 .h 文件中:
@property (nonatomic, strong) IBOutletCollection(UIButton) NSArray *buttons;
在 .m 文件中:
for (UIButton *label in buttons) {
label.layer.borderWidth = 1.5f;
label.layer.borderColor = (__bridge CGColorRef)([UIColor colorWithRed:87.0/255.0 green:49.0/255.0 blue:42.0/255.0 alpha:1]);
label.layer.backgroundColor = (__bridge CGColorRef)([UIColor colorWithRed:134.0/255.0 green:98.0/255.0 blue:98.0/255.0 alpha:1]);
}
IBOutletCollection 连接到我视图中现有的 24 个按钮,最初是灰色的,当我运行这个函数来修改按钮的颜色时,它们都变成了白色,我该如何解决这个问题?
【问题讨论】:
标签: objective-c iboutlet iboutletcollection