我在一個視圖上有42個自定義按鈕。我怎樣才能通過按他們中的任何一個編輯我想要創建的按鈕。自定義按鈕動作
int a=0; int b=1;
int otstup=10;
for (int i=1; i<=42; i++) {
CGRect frameBtn = CGRectMake(a+60+otstup, b+otstup, 45, 45);
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:frameBtn];
[button setBackgroundImage:[UIImage imageNamed:@"EmptyCoin.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(pressBtn:) forControlEvents:UIControlEventTouchUpInside];
[button setTag:i];
[self.view addSubview:button];
a=a+50;
if (i%7 == 0)
{
a=0;
b=b+45;
}
}
上點擊一個按鈕,你想改變這種特定的按鈕的屬性?請明確指出你想要做什麼? – 2013-03-06 12:22:30
「,通過按下其中任何一個編輯我想要創建的按鈕。」 - 嗯?我不明白。 – 2013-03-06 12:23:12
我按下按鈕7.和8按鈕更改圖片。等 – user2128989 2013-03-06 12:31:59