低数字时更改标签文本颜色

时间:2013-06-08 16:11:50

标签: nsstring uilabel

我正在开发一个测试/演示应用程序,用户在UITextField中输入分数,然后点击UIButton,然后在UIText标签中显示分数的总和。我想要最低分来改变UILabel颜色或改变UILabel文本颜色为最低数字。这样用户就可以轻松查看得分最低的人。按下按钮后,分数计算工作正常,只想添加此功能。

- (IBAction)calculateScore:(id)sender{

//Player 1

float p112=([_player1Text12.text floatValue]);
float p111=([_player1Text11.text floatValue]);
float p110=([_player1Text10.text floatValue]);
float p19=([_player1Text9.text floatValue]);
float p18=([_player1Text8.text floatValue]);
float p17=([_player1Text7.text floatValue]);
float p16=([_player1Text6.text floatValue]);
float p15=([_player1Text5.text floatValue]);
float p14=([_player1Text4.text floatValue]);
float p13=([_player1Text3.text floatValue]);
float p12=([_player1Text2.text floatValue]);
float p11=([_player1Text1.text floatValue]);
float p1total= p112+p111+p110+p19+p18+p17+p16+p15+p14+p13+p12+p11+([_player1Text0.text floatValue]);

_player1Score.text = [[NSString alloc] initWithFormat:@"%2.f", p1total];

我知道有更简单的方法可以进行我的计算(就代码量而言),并且可能无法通过我设置的方式来突出显示高数字。

同样,我只是在学习,所以这对我来说都是实验性的,不会发表。我还有很多学习/阅读材料。

谢谢!

0 个答案:

没有答案