默认四种状态
cell.accessoryType = UITableViewCellAccessoryNone;//cell没有任何的样式
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;//cell的右边有一个小箭头,距离右边有十几像素;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;//cell右边有一个蓝色的圆形button;
cell.accessoryType = UITableViewCellAccessoryCheckmark;//cell右边的形状是对号;
自定义accessoryType属性
cell.textLabel.text = @"优惠券";
//创建btn/imageView
self.button = [[UIButton alloc]init];
//设置图片
[self.button setBackgroundImage:[UIImage imageNamed:@"zhifu_weixuan"] forState:UIControlStateNormal];
[self.button setBackgroundImage:[UIImage imageNamed:@"zhifu_xuanzhong"] forState:UIControlStateSelected];
//自适应
[self.button sizeToFit];
self.button.backgroundColor= [UIColor clearColor];
//添加点击事件----点击事件中改变 选中状态
[self.button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//赋值回去
cell.accessoryView= self.button;
点击事件
- (void)btnClick:(UIButton *)btn {
btn.selected = !btn.selected;
}