2011-10-05 40 views
1

當我的.xib文件加載這時間UITableViewCell是裝滿了黑色背景顏色,對於這一點,我使用如何使透明的UIButton中的UITableView細胞

cell.contentView.backGroundColor = [UIColor blackColor] 

UITableViewCell一個UIButton用「自定義「按鈕類型是由程序生成的 因此該地區涵蓋UIButton是不是transparent(或單元格背景 - 黑顏色不顯示),它是一種白色,,,

我要讓UIButton使用透明背景

SO我怎麼能?

+0

您是否使用自定義單元格? –

回答

1
UIButton *button; 
button.backgroundColor = [UIColor clearColor]; 
+0

親愛的,朋友我也試過這個,但它不起作用, – prithvi

+0

我在UITableViewCell – prithvi

+0

請提供您用來創建按鈕的代碼。 – Nekto

1
try this one it work for me 
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
     [button addTarget:self 
        action:@selector(aMethod:) 
     forControlEvents:UIControlEventTouchDown]; 
     [button setTitle:@"Show View" forState:UIControlStateNormal]; 
     button.frame = CGRectMake(0.0, 5.0, 160.0, 40.0); 
     [button setBackgroundColor:[UIColor clearColor]]; 
     [cell.contentView addSubview:button]; 
+0

謝謝你,我的朋友,這是工作.. – prithvi

0

你爲什麼不使按鈕的圖像與你想顯示和添加爲按鈕的背景與按鈕類型的自定義文本一起。