2

I'm trying to round the chat bubbles by applying bezierPathWithRoundedRect to them. Everything works almost perfect. But for some strange reason in some cases one of the corners seems to me much bigger than others. Why it happens and hou to avoid it?

My code:

bubbleContainer.layer.cornerRadius = 6.0;

UIRectCorner cornersOut = (UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft);
UIRectCorner cornersIn = (UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomRight);
UIRectCorner corners = isOutMessage ? cornersOut : cornersIn;

UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:bubbleContainer.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(17.0, 17.0)];
CAShapeLayer * maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = bubbleContainer.bounds;
maskLayer.path  = maskPath.CGPath;

bubbleContainer.layer.mask = maskLayer;

enter image description here

As you can see, bubbles with text "111" and "1111" have a different top right corner. There is no other masking for bubbles and after applying tha mask bubbles do not resize.

  • You may try examining the CGPath to try to figure out at what point things go bad. https://gist.github.com/markd2/7bd2a5e2969b000f296828b3bcbf49f8 may be useful. The Xcode UI inspector may also help. – jcaron Jan 03 '18 at 15:13

0 Answers0