2010-04-10 95 views
1

如何獲得一個按鈕與一個specifyed標籤按鈕與標籤

ID喜歡,然後將其轉換爲一個UIButton,並改變阿爾法

回答

1
UIView* view = [theViewContainingThatButton viewWithTag:tag]; 
view.alpha = 0.5; 

你並不需要轉換查看UIButton來更改其alpha。但如果真的需要,你可以添加一個(UIButton*)

+1

theViewContainingThatButton? 這是AppNameViewController嗎? – 2010-04-10 08:10:37

+1

@Sam:可以使用該按鈕的任何超級視圖。你可以使用'viewController.view'或甚至'window'。 – kennytm 2010-04-10 08:30:34

+0

是.. self.view似乎也在工作:D 謝謝! – 2010-04-10 08:39:53

6
UIButton *button=(UIButton *)[self.view viewWithTag:tag]; 
button.alpha=0.5;