UITableViewCellAccessory Removal Animation

Is there a way to animate the removal of a UITableView cellular accessory?

I am currently displaying the UITableViewCellAccessoryDisclosureIndicator identifier, but I would like to animate the replacement indicator using UISwitch in all visible cells of the table.

I tried something like this:

[UIView animateWithDuration:0.3
                 animations:^{
                   for (SwitchTableViewCell *cell in self.tableView.visibleCells)
                   {
                     cell.accessoryType = UITableViewCellAccessoryNone;
                   }                     
                 }];

... but, unfortunately, this does not affect. The disclosure indicator suddenly disappears, and the width of the contentView goes one step, rather than a smooth transition.

+3
source share
1 answer

accessoryType . , . , UISwitch - . cell.editingAccessoryType = theSwitch; tableView:cellForRowAtIndexPath:. / .

, , :

[UIView animateWithDuration:0.3 animations:^{
    for(SwitchTableViewCell *cell in self.tableView.visibleCells) {
        [[cell valueForKey:@"_accessoryView"] setAlpha:0.0];
    }
} completion:^(BOOL done) {
    for(SwitchTableViewCell *cell in self.tableView.visibleCells) {
        cell.accessoryView = theSwitch;
    }
}];

, , _accessoryView.

+3

Source: https://habr.com/ru/post/1781863/


All Articles