我已將一個半透明圖像應用於我的UITableViewCell.contentView。每當我添加我的自定義accessoryView的,它不具備正確的背景如下所示:UITableViewCell的一致背景
這是相關代碼:
UITableViewCell *tableViewCell = [[UITableViewCell alloc] init];
[tableViewCell.contentView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-bg.png"]]];
//[tableViewCell.backgroundView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-bg.png"]]];
tableViewCell.textLabel.text = @"Test";
UIButton *accessoryButton = [UIButton buttonWithType:UIButtonTypeCustom];
[accessoryButton setBackgroundImage:[UIImage imageNamed:@"arrow.png"] forState:UIControlStateNormal];
[accessoryButton setFrame:CGRectMake(0, 0, 34, 34)];
tableViewCell.accessoryView = accessoryButton;
我也嘗試添加背景圖片到backgroundView
而不是contentView
,但它根本不顯示。如何解決這個問題?謝謝