ios - 如何改变UITableView的编辑风格?

标签 ios objective-c cocoa-touch

从下图中,我想更改多选按钮的颜色和选中时的背景颜色(蓝色部分)。

editingStyle定义如下

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete|UITableViewCellEditingStyleInsert;
}

我尝试设置tableView的tintColor,多选按钮的颜色变了,但是背景色没有变。

enter image description here

最佳答案

您需要更改每个单元格的 tintColormultipleSelectionBackgroundView

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    //...

    cell.tintColor = UIColor.orange

    let bgview = UIView()
    bgview.backgroundColor = UIColor.purple
    cell.multipleSelectionBackgroundView = bgview

    //...
}

sample

关于ios - 如何改变UITableView的编辑风格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44643522/

相关文章:

objective-c - 清除UIImage使用的内存— UIImageView.image = nil不这样做

ios - 如何检查我的 IPA 文件支持的 IOS 设备

objective-c - Objective-C 中的简单 http post 示例?

ios - 在 View 中绘制多个 UIBezierPath

ios - 为什么我收到 ObjC ClassNotFoundException : GADInterstitial in RoboVM?

ios - 具有双值的 TableView 单元格

ios - 视频 iOS 11/xcode 9

ios - 未调用 Apple 推送通知委托(delegate)方法

iphone - 在 iPhone 上的标签栏项目上显示更新的角标(Badge)计数的最佳方式

ios - 从屏幕边缘滑动到 UICollectionView