使用 moveRow(at:,to:) 时如何更改 UITableViewCell 的不透明度和颜色

How can I change opacity and color of UITableViewCell when i use moveRow(at:,to:)

这是我的代码。我的 swift 版本是 4.

tableview.beginUpdates() 
tableview.moveRow(at: IndexPath(row: indexPath.row, section: 0), to: IndexPath(row: 0, section: 2))
tableview.endUpdates()

更改表视图部分时出现问题。因为每个部分都有其他不透明度和颜色,所以我希望不透明度和颜色在使用 moveRow(at:,to:) 时立即改变。

但是我找不到我该怎么做。请帮助我!

假设您有一个自定义 UITableViewCell class。您可以在 class 中编写一个函数来操纵单元格的外观。假设您在 class 中有一堆插座,您可以创建一个函数来更改这些视图元素。透明度和颜色等

在 cellForRowAtIndexPath 方法内的单元格上调用此函数:

let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) as! MyCustomCellClass
cell.apperanceFunction(alpha: Double, background: UIColor)

在 if 或 switch 内的特定部分,我必须假设你有。当您将单元格移动到该部分时,应再次调用 cellForRowAtIndexPath 并且应在该特定单元格上调用该函数。如果没有,您始终可以使用 ViewController 中的 cellForRow(at: indexPath) 函数手动找到该单元格,并专门调用该函数。

希望这是有道理的...但是当这是您提供的唯一代码时有点困难。