gpt4 book ai didi

iphone - 每次单击 iPhone 中的按钮都会更改 View 的背景颜色

转载 作者:搜寻专家 更新时间:2023-10-30 19:55:03 24 4
gpt4 key购买 nike

-(IBAction) changeColOnClick:(id)sender
{
NSArray *colors = [NSArray arrayWithObjects:@"[UIColor brownColor]",@"[UIColor blackColor]",@"[UI greenColor]",@"[UIColor redColor]", nil];

self.view.backgroundColor = [colors objectAtIndex:i];
// ERROR::changebackground[1089:207] -[NSCFString CGColor]: unrecognized selector sent to instance 0x357c

//label.text = [colors objectAtIndex:i]; //i is defined in the implementation
i++;

if(i==[colors count]-1)
{
i=0;
}
}

最佳答案

像这样修改你的代码。它会起作用

-(IBAction) changeColOnClick:(id)sender
{
NSArray *colors = [NSArray arrayWithObjects:[UIColor brownColor],[UIColor blackColor],[UI greenColor],[UIColor redColor], nil];

self.view.backgroundColor = [colors objectAtIndex:i];
//label.text = [colors objectAtIndex:i]; //i is defined in the implementation
i++;

if(i==[colors count]-1)
{
i=0;
}
}

关于iphone - 每次单击 iPhone 中的按钮都会更改 View 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13473801/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com