Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Objective-C中的UIButton数组上循环_Objective C_Arrays_Uibutton_Nsarray_Layer - Fatal编程技术网

在Objective-C中的UIButton数组上循环

在Objective-C中的UIButton数组上循环,objective-c,arrays,uibutton,nsarray,layer,Objective C,Arrays,Uibutton,Nsarray,Layer,我有一个按钮数组,我想改变其中的一些属性 数组如下所示: NSArray *buttons = @[_smallButton, _mediumButton, _largeButton, _xlargeButton]; 按钮是: @property (weak, nonatomic) IBOutlet UIButton *smallButton; @property (weak, nonatomic) IBOutlet UIButton *mediumButton; @property (wea

我有一个按钮数组,我想改变其中的一些属性

数组如下所示:

NSArray *buttons = @[_smallButton, _mediumButton, _largeButton, _xlargeButton];
按钮是:

@property (weak, nonatomic) IBOutlet UIButton *smallButton;
@property (weak, nonatomic) IBOutlet UIButton *mediumButton;
@property (weak, nonatomic) IBOutlet UIButton *largeButton;
@property (weak, nonatomic) IBOutlet UIButton *xlargeButton;
现在我想更改所有
borderColor
s,并在数组上的循环中为每个设置标记:

for(int i=0; i< buttons.count; i++) {
   [buttons[i] layer].borderColor = [UIColor darkGrayColor].CGColor;
   [buttons[i] setTag:i];
}
for(int i=0;i
关键是
setTag
工作正常,可应用于所有按钮,但
borderColor
仅针对第一项更改,而不是所有按钮


有人知道我遗漏了什么吗?

尝试将
边框宽度
拐角半径
设置为所有这些参数,即:

for(int i=0; i< buttons.count; i++) {
   [buttons[i] layer].borderColor = [UIColor darkGrayColor].CGColor;
   [buttons[i] layer].borderWidth = 1;
   [buttons[i] layer].cornerRadius = 4;
   [buttons[i] setTag:i];
}
for(int i=0;i
尝试将
边框宽度
拐角半径
设置为所有这些参数,即:

for(int i=0; i< buttons.count; i++) {
   [buttons[i] layer].borderColor = [UIColor darkGrayColor].CGColor;
   [buttons[i] layer].borderWidth = 1;
   [buttons[i] layer].cornerRadius = 4;
   [buttons[i] setTag:i];
}
for(int i=0;i
哦,这是一个非常严重的错误,问题是borderWidth,我在情节提要中设置了第一个按钮borderWidth,但忘记设置其余按钮,谢谢。哦,这是一个非常严重的错误,问题是borderWidth,我在情节提要中设置了第一个按钮borderWidth,但忘了设置其余按钮borderWidth,谢谢。