我定製UIButton
編程這裏:正在按下UIButton的UIControlState是什麼?
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setSelected:YES];
button.frame = CGRectMake(x, y, width, height);
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateSelected];
[button setTitle:@"Button Title" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"buttonActive.png"] forState:UIControlStateSelected];
[button setBackgroundImage:[UIImage imageNamed:@"buttonActive.png"] forState:UIControlStateHighlighted];
[button setBackgroundImage:[UIImage imageNamed:@"buttonActive.png"] forState:UIControlStateDisabled];
的問題是,如果我按住圖像背景圖像中消失,直到我放開了它...
我想補充一點,圖像文件的名稱是區分上一個敏感設備,但不在模擬器中。這讓我撓了腦袋幾次:) – Keller
@Sid:我知道**圖像名稱區分大小寫**。我在iPhone模擬器上測試,但應該反應相同... –
@Keller::) ... – Sid