Iphone 如何在UITableView单元格中创建透明的UIButton

Iphone 如何在UITableView单元格中创建透明的UIButton,iphone,objective-c,ios,Iphone,Objective C,Ios,加载.Xib文件时,UITableViewCell将填充黑色背景色,为此,我使用 cell.contentView.backGroundColor = [UIColor blackColor] 但是在UITableViewCell中,一个带有“自定义”按钮类型的UIButton是通过编程生成的 因此,ui按钮覆盖的区域是非透明的(或单元格背景-黑色不显示),它是白色 我想用透明的背景制作ui按钮 那么我该怎么做呢?为什么不制作一个按钮的图像以及要显示的文本,并将其添加为按钮背景,按钮类型为“自

加载.Xib文件时,
UITableViewCell
将填充黑色背景色,为此,我使用

cell.contentView.backGroundColor = [UIColor blackColor]
但是在
UITableViewCell
中,一个带有“自定义”按钮类型的
UIButton
是通过编程生成的 因此,
ui按钮
覆盖的区域是非透明的(或单元格背景-黑色不显示),它是白色

我想用透明的背景制作
ui按钮


那么我该怎么做呢?

为什么不制作一个按钮的图像以及要显示的文本,并将其添加为按钮背景,按钮类型为“自定义”。

您需要先将按钮类型更改为“自定义”@普里特维
UIButton *button;
button.backgroundColor = [UIColor clearColor];
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];