“insetGrouped”样式中单元格预览的圆角(iOS 13)

Mik*_*tev 7 animation contextmenu uitableview ios ios13

我发现 UITableView 在样式中存在一个恼人的问题insetGrouped。实现contextMenuConfigurationForRowAtIndexPath方法时,它允许使用上下文操作进行查看和弹出单元格预览。除了 iOS 预览窗口圆角时的功能外,一切正常。

边角不是圆角的

但是,如果桌子采用其他任何样式(例如,普通),则角会变成圆角。此外,普通模式下的动画更加“平滑”,并且预览会稍微缩小。

边角是圆角的

我还发现 iOS 会圆化样式中第一个单元格的顶角和最后一个单元格的底角insetGrouped

有没有人遇到过类似的行为UITableView

Tài*_*iến 5

您可以通过实现方法“previewForHighlightingContextMenuWithConfiguration”为单元格设置圆角

- (UITargetedPreview *)tableView:(UITableView *)tableView previewForHighlightingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration {
NSIndexPath *index = (NSIndexPath *)configuration.identifier;
SharedTableViewCell *cell = [self.tableView cellForRowAtIndexPath:index];

UIPreviewParameters *parameters = [[UIPreviewParameters alloc] init];
parameters.backgroundColor = UIColor.clearColor;
parameters.visiblePath = [UIBezierPath bezierPathWithRoundedRect:cell.bounds cornerRadius:10.0];
UITargetedPreview *targetedPreview = [[UITargetedPreview alloc] initWithView:cell parameters:parameters];

return targetedPreview;
Run Code Online (Sandbox Code Playgroud)

}