开发者

iphone how to I make a uitableviewcellaccessorydisclosureindicator background transparent?

开发者 https://www.devze.com 2023-01-12 00:42 出处:网络
Can someone please explain to me how I can make a uitableviewcellaccessorydisclosureindicator\'s background in a UITableViewCell transparent?

Can someone please explain to me how I can make a uitableviewcellaccessorydisclosureindicator's background in a UITableViewCell transparent?

Right now I'm fa开发者_C百科cing this problem:

alt text http://www.bubl3r.com/disclosure.jpg


Just found the answer. Turns out it was just 3 lines & having to define my own disclosure indicator .png image with a transparent background:

UITableViewCell *bgView = [[UITableViewCell alloc] initWithFrame:CGRectZero];
    bgView.backgroundColor=indexPath.row % 2? [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1]: [UIColor whiteColor];
    bgView.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"disclosure.png"]];
    cell.backgroundView=bgView; 


    return cell;


In your UITableView's delegate, override the delegate method tableView:willDisplayCell:forRowAtIndexPath:. In there, set the cell's backgroundColor property to whatever color, and the accessory view's background color should match.


More detail from anshuchimala's answer:

cell.contentView.backgroundColor=[UIColor grayColor];//or any color
cell.backgroundColor=[UIColor grayColor];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.accessoryView.backgroundColor=[UIColor clearColor];
0

精彩评论

暂无评论...
验证码 换一张
取 消