title: UIBezierPath arc and rectangle problem on iPhone X family but not on earlier phones
body: <p>I have created a Objective-C category for UIView to draw rounded corners. I am trying to implement a Pill button and the function is working except on iPhone X family. Because the Arc is at the end of the UIView, I think I have to draw the rest of the view as a rectangle to fill in. If there is a better way to do this I would love to know. Here is the function.</p>
  
  <pre><code>- (void)setRounded:(BOOL)clockwise borderColor:(UIColor *)borderColor {
      CGRect rect = self.bounds;
  
      CGFloat offset = CGRectGetMidY(rect);
      NSAssert(rect.size.width-rect.origin.x &gt;= offset, @"width too small %f &lt; %f", rect.size.width, offset);
  
      UIBezierPath *maskPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(clockwise?rect.size.width-rect.origin.x-offset:rect.origin.x+offset, offset) radius:offset startAngle:GLKMathDegreesToRadians(270) endAngle:GLKMathDegreesToRadians(90) clockwise:clockwise];
      DLog(@"(clockwise: %@) maskPath: %@", clockwise?@"true":@"false", NSStringFromCGRect([maskPath bounds]));
      [maskPath setUsesEvenOddFillRule:NO];
      UIBezierPath *squarePath = [UIBezierPath bezierPath];
  
      if (clockwise) {
          [squarePath moveToPoint:CGPointMake(rect.origin.x, rect.origin.y)];
          [squarePath addLineToPoint:CGPointMake(rect.size.width-rect.origin.x-offset, rect.origin.y)];
          [squarePath addLineToPoint:CGPointMake(rect.size.width-rect.origin.x-offset, rect.origin.y+rect.size.height)];
          [squarePath addLineToPoint:CGPointMake(rect.origin.x, rect.origin.y+rect.size.height)];
          [squarePath addLineToPoint:CGPointMake(rect.origin.x, rect.origin.y)];
      } else {        
          [squarePath moveToPoint:CGPointMake(rect.origin.x+offset, rect.origin.y)];
          [squarePath addLineToPoint:CGPointMake(rect.size.width-rect.origin.x, rect.origin.y)];
          [squarePath addLineToPoint:CGPointMake(rect.size.width-rect.origin.x, round(rect.origin.y+rect.size.height))];
          [squarePath addLineToPoint:CGPointMake(rect.origin.x+offset, round(rect.origin.y+rect.size.height))];
          //[squarePath addLineToPoint:CGPointMake(rect.origin.x+offset, rect.origin.y)];
          [squarePath closePath];
      }
      DLog(@"squarePath: %@", NSStringFromCGRect([squarePath bounds]));
      [maskPath appendPath:squarePath];
  
      CAShapeLayer *maskLayer = [CAShapeLayer layer];
      maskLayer.frame = rect;
      maskLayer.path = maskPath.CGPath;
  
      self.layer.mask = maskLayer;
  
      CAShapeLayer *shape = [CAShapeLayer layer];
      shape.frame = self.frame;
      shape.path = maskPath.CGPath;
      shape.lineWidth = 1.0;
      shape.strokeColor = borderColor.CGColor;
      shape.fillColor = borderColor.CGColor;
      [self.layer addSublayer:shape];
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/dpjPR.png" alt="iPhoneX extra line"></p>