uibuttontypedetaildisclosure自定义图像

时间:2013-05-14 13:32:03

标签: ios objective-c uibutton

是否可以将UIButtonTypeDetailDisclose的图像从默认图像更改为更有趣的图像。但是,请注意我要求按钮,而不是一种类型的uibutton。

1 个答案:

答案 0 :(得分:1)

您必须更改单元格的附件视图。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath

// code for initializing the cell..

UIImage *image = [UIImage imageNamed:@"interestingImage.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(44.0, 44.0, image.size.width, image.size.height);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];

[button addTarget:self action:@selector(accessoryButtonTapped:)  forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor = [UIColor clearColor];
cell.accessoryView = button;

return cell;
}