问题
On iOS 11 device on deleting a UITableViewCell unexpected white background appears for some reason however all background colors are set to blue in storyboard (works fine on iOS10).
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.bookmarks removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
Tried all types of UITableViewRowAnimation, doesn't solve the problem.
回答1:
Try it (you can choose appearanceWhenContainedInInstancesOfClasses instead).
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
[[UITableViewCell appearance] setBackgroundColor:[UIColor clearColor]];
return YES;
}
回答2:
I tried everything that's possible and only thing that work was
adding
UITableViewCell.appearance().backgroundColor = UIColor.clear
in didFinishLaunchingWithOptions
回答3:
Just a suggestion: Make sure all elements have a transparent background color or the light blue you are using. Apparently there is one that still has a white background color, could be the cell content view (if you have one) or the cell background.
来源:https://stackoverflow.com/questions/46477291/ios-11-xcode-9-uitableviewcell-white-background-flickers-on-delete