背景随机颜色和按钮点击变色
2016-09-13 本文已影响0人
Fade1992
btn.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1];
[button setImage:[UIImag imageNamed:@"xxx.png"]forState:UIControlStateNormal];//未按下时
[button setImage:[UIImage imageNamed:@"xxx.png"] forState:UIControlStateHighlighted];//按下时
[button setBackgroundImage:[UIImag imageNamed:@"xxx.png"]forState:UIControlStateNormal];//未按下时背景颜色
[button setBackgroundImage:[UIImage imageNamed:@"xxx.png"] forState:UIControlStateHighlighted];//按下时背景颜色