2013-07-26 71 views
0

我嘗試按鈕圖像設置alpha值驗證碼:爲ios中的uibutton setimage設置alpha值?

UIImageView *imageTopView = [[UIImageView alloc] initWithImage: 
    [UIImage imageNamed:@"Top_80.png"]];  
imageTopView.alpha = 0.5; 

topBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 

[topBtn addTarget:self action:@selector(btnRotatingObj:) 
     forControlEvents:UIControlEventTouchUpInside]; 

[topBtn setImage: imageTopView.image forState:UIControlStateNormal]; 
    [topBtn setTitle:@"TOP" forState:UIControlStateNormal]; 

[self.view addSubview:topBtn]; 

它不工作.....

回答

0

您與您的圖像視圖的圖像設置按鈕的圖像。你的圖像視圖有0.5的alpha,但當然不是你的圖像。

相反,添加圖像視圖爲您的按鈕的子視圖:

[topBtn addSubView:imageTopView]; 
+0

謝謝Mundi..its工作完美 – prabu