Always update the path of the attachmentView's mask to handle reuse.

This commit is contained in:
Doug
2021-07-14 10:15:50 +01:00
parent c68535984d
commit c7176c7423
2 changed files with 14 additions and 2 deletions
+13 -2
View File
@@ -1039,10 +1039,21 @@ const CGFloat kTypingCellHeight = 24;
- (void)applyMaskToAttachmentViewOfBubbleCell:(MXKRoomBubbleTableViewCell *)cell
{
if (cell.attachmentView && !cell.attachmentView.layer.mask)
if (cell.attachmentView)
{
UIBezierPath *myClippingPath = [UIBezierPath bezierPathWithRoundedRect:cell.attachmentView.bounds cornerRadius:6];
CAShapeLayer *mask = [CAShapeLayer layer];
CAShapeLayer *mask;
// check for an existing mask in case the cell is being reused, otherwise create a new one
if ([cell.attachmentView.layer.mask isKindOfClass:[CAShapeLayer class]])
{
mask = (CAShapeLayer*)cell.attachmentView.layer.mask;
}
else
{
mask = [CAShapeLayer layer];
}
mask.path = myClippingPath.CGPath;
cell.attachmentView.layer.mask = mask;
}