iOS UITableViewCell 左滑删除时,修改删除按钮背景颜色,默认是红色的
2017-03-24 09:55
441 查看
方法1:
方法2:
开发中可能会有改变这个按钮背景色的需求,如微信的通讯录左滑备注按钮就是灰色的,实现这个需求我们需要自定义cell,在自定义的cell中重写layoutSubviews这个方法,找到UITableViewCellDeleteConfirmationView修改它的背景色即可。
1 // 自定义左滑显示编辑按钮 2 -(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath 3 { 4 5 UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault 6 title:@"跟进" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { 7 NSLog(@"跟进"); 8 9 }]; 10 11 UITableViewRowAction *rowActionSec = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault 12 title:@"快速备忘" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { 13 NSLog(@"快速备忘"); 14 15 }]; 16 rowActionSec.backgroundColor = [UIColor colorWithHexString:@"f38202"]; 17 rowAction.backgroundColor = [UIColor colorWithHexString:@"d9d9d9"]; 18 19 NSArray *arr = @[rowAction,rowActionSec]; 20 return arr; 21 }
方法2:
开发中可能会有改变这个按钮背景色的需求,如微信的通讯录左滑备注按钮就是灰色的,实现这个需求我们需要自定义cell,在自定义的cell中重写layoutSubviews这个方法,找到UITableViewCellDeleteConfirmationView修改它的背景色即可。
1 - (void)layoutSubviews 2 { 3 [super layoutSubviews]; 4 5 for (UIView *subView in self.subviews) { 6 NSString *subViewName =NSStringFromClass([subView class]); 7 if ([subViewName isEqualToString:@"UITableViewCellDeleteConfirmationView"]) { 8 subView.backgroundColor = [UIColor lightGrayColor]; 9 ((UIView *)[subView.subviews firstObject]).backgroundColor = [UIColor lightGrayColor]; 10 11 } 12 } 13 }
相关文章推荐
- 85.如何更改iOS上的UISearchBar组件的内部背景UITextField颜色 修改UISearchBar删除按钮ClearButton
- ios UITableViewCell 左滑删除时,改变删除按钮背景颜色
- iOS 开发 解决UITableViewcell单选动态改变cell文字和背景颜色的功能,且第一次默认选择第一个cell
- ios 修改UItableviewcell点击时的颜色
- cell删除时,系统红色删除颜色修改
- iOS UINavigationController修改导航栏标题、按钮文字以及背景的颜色
- ios中UITableViewCell选中后的颜色设置和背景图片
- 修改IOS UITableViewCell箭头颜色方法
- iOS中修改头部tabBarButton 默认按钮的颜色和默认字体颜色
- 修改Chrome浏览器默认背景颜色为浅绿色
- 修改Chrome浏览器默认背景颜色为浅绿色
- ios设置导航栏背景图片、返回按钮背景、标题颜色等等
- 修改 Chrome 浏览器默认背景颜色为浅绿色
- 设置状态栏、导航栏背景颜色,修改导航栏返回按钮颜色
- ios中UITableViewCell选中后的颜色设置
- IOS_修改TableView的删除按钮的文本
- 修改Chrome浏览器默认背景颜色为豆沙绿护眼色
- 修改Cell的点击效果(背景 颜色)
- 修改chrome默认背景颜色为浅绿色
- Yii-bootstrap TbMenu修改默认背景颜色(background-color)