以编程方式增加indexPath

时间:2018-11-07 18:05:45

标签: swift uicollectionview

如何以编程方式增加类型为indexPath的var?例如,当前indexPath为[0,44],我希望在执行特定操作后indexPath为[0,45]?

1 个答案:

答案 0 :(得分:2)

由于您正在使用集合视图,因此您似乎想增加item属性。

someIndexPath.item += 1

如果需要,您还可以在旧版本的基础上创建新的IndexPath

let newIndexPath = IndexPath(item: oldIndexPath.item + 1, section: oldIndexPath.section)