我是 iOS 新手,只有 Action Script 3.0 作为编程背景。到目前为止,Objective C 对我来说是难以置信的陌生。我正在使用最新版本的 Xcode,并尝试通过小步骤来学习,对于像我这样的新手来说,太多教程的起点太高了。
我试图让标签或按钮在被触摸时改变字体颜色,并在再次被触摸时恢复到原来的颜色。我知道这可能非常简单,但我需要从某个地方开始。非常感谢。
最佳答案
当 UIButton
被触摸时,很容易改变它的颜色属性。
-(IBAction)changeColor:(id)sender
{
UIButton *btn = (UIButton *)sender;
if(btn.enabled)
{
btn.enabled=NO;
btn.backgroundColor=[UIColor blueColor];
}
else
{
btn.enabled=YES;
btn.backgroundColor=[UIColor greenColor];
}
}
关于ios - 在 iOS 中触摸时更改按钮的字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12505114/