Reputation: 1422
I am setting view when swipe tableview cell like as 1st view in table it need to be stick on as second view and change its color.
Is it possible in Swift 4 and iOS?
Upvotes: 0
Views: 827
Reputation: 2811
Once you are getting the swipe gesture in view controller you do the next:
func didSwipe(_ cell: UITableViewCell) {
let indexPath = tableView.indexPath(for: cell)
if indexPath.row + 1 < myViewModels.count - 1 {
// Store the info from the next view model to the current one
myViewModels[indexPath.row].update(with: myViewModels[indexPath.row + 1])
tableView.reloadItems(at: [indexPath])
}
}
myViewModels is an array of object(contains data, colors, etc) that you are displaying Instead of update you can manually update necessary fields
The code may have an errors but the idea should be clear
Upvotes: 1