Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
Ios4 iPhone:我如何交换UIButton文本颜色?_Ios4_Uibutton - Fatal编程技术网

Ios4 iPhone:我如何交换UIButton文本颜色?

Ios4 iPhone:我如何交换UIButton文本颜色?,ios4,uibutton,Ios4,Uibutton,我在运行时创建UIButtons并处理按钮触摸;我想改变按钮文本颜色时,按钮被点击,并返回到原来的颜色时,另一个按钮被触摸;我如何以编程方式完成它 [aButton setTitleColor:[UIColor grayColor] forState: UIControlStateNormal] 然后,您可以在单击另一个按钮时使用与上面相同但颜色不同的代码来更改颜色 然后,当单击另一个按钮时,您可以使用与上述相同的代码更改颜色,但颜色不同。循环浏览按钮的一种方法是在要循环浏览的按钮上设置标记。

我在运行时创建UIButtons并处理按钮触摸;我想改变按钮文本颜色时,按钮被点击,并返回到原来的颜色时,另一个按钮被触摸;我如何以编程方式完成它

[aButton setTitleColor:[UIColor grayColor] forState: UIControlStateNormal]
然后,您可以在单击另一个按钮时使用与上面相同但颜色不同的代码来更改颜色


然后,当单击另一个按钮时,您可以使用与上述相同的代码更改颜色,但颜色不同。

循环浏览按钮的一种方法是在要循环浏览的按钮上设置标记。我使用这段代码为每个UITextFile设置键盘返回键类型:

NSInteger tag = 1;  
UIView *aView;
while ((aView = [contentView viewWithTag:tag])) {  
    if([aView isKindOfClass:[UITextField class]]){
        [(UITextView *)aView setReturnKeyType:UIReturnKeySend];
    }
    tag++;  
}
所以我猜你可以这样做:

NSInteger tag = 1;  
UIView *aView;
while ((aView = [contentView viewWithTag:tag])) {  
    if([aView isKindOfClass:[UIButton class]]){
        [ aView setTitleColor:[UIColor grayColor] forState: UIControlStateNormal];
    }
    tag++;  
}

循环浏览按钮的一种方法是在要循环浏览的按钮上设置标记。我使用这段代码为每个UITextFile设置键盘返回键类型:

NSInteger tag = 1;  
UIView *aView;
while ((aView = [contentView viewWithTag:tag])) {  
    if([aView isKindOfClass:[UITextField class]]){
        [(UITextView *)aView setReturnKeyType:UIReturnKeySend];
    }
    tag++;  
}
所以我猜你可以这样做:

NSInteger tag = 1;  
UIView *aView;
while ((aView = [contentView viewWithTag:tag])) {  
    if([aView isKindOfClass:[UIButton class]]){
        [ aView setTitleColor:[UIColor grayColor] forState: UIControlStateNormal];
    }
    tag++;  
}

好的,但是如果我有20个按钮,我应该每次在它们之间循环吗?我认为自动处理状态是很好的,但是如果我有20个按钮,我应该每次在它们之间循环吗?我认为自动处理状态会很好