title: UIButton with rounded corners and border
body: <p>I want to set border on UIButton and rounded corners ONLY in one side </p>
  
  <p>I use this code:</p>
  
  <pre><code>//set rounded corners on top
  UIBezierPath *maskPath =  [UIBezierPath bezierPathWithRoundedRect:self.scanButton.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(10.0, 10.0)];
  
  CAShapeLayer *maskLayer = [CAShapeLayer layer];
  maskLayer.frame = self.scanButton.bounds;
  maskLayer.path = maskPath.CGPath;
  
  self.scanButton.layer.mask = maskLayer;
  
  // set border
  self.scanButton.layer.borderColor = [UIColor blackColor].CGColor;
  self.scanButton.layer.borderWidth = 2.0f;
  [self.scanButton.layer setMasksToBounds:YES];
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/gnam9.png" alt="enter image description here"></p>
  
  <p>How can I make proper border in top corners?</p>