title: How to make a UIView with optional rounded corners and border?
body: <p>I am applying  corner radius to a <code>UIView</code> i.e. <code>UIRectCornerTopLeft</code> and <code>UIRectCornerTopRight</code>. When I apply this, the border is gone at the corners. How to avoid this?</p>
  
  <p>This is how I apply border to <code>UIView</code>:</p>
  
  <pre><code> [self.middleView addRoundedCorners:UIRectCornerTopLeft|UIRectCornerTopRight withRadii:CGSizeMake(4, 4)];
   self.middleView.layer.borderWidth = 0.5f;
   self.middleView.layer.borderColor = [[UIColor colorWith8BitRed:0 green:0 blue:0 alpha:0.25]
  </code></pre>
  
  <p>And this is a category I am using for applying optional rounded corners:</p>
  
  <pre><code>   #import "UIView+Roundify.h"
  
     @implementation UIView (Roundify)
    - (void)addRoundedCorners:(UIRectCorner)corners withRadii:(CGSize)radii {
     CALayer *tMaskLayer = [self maskForRoundedCorners:corners withRadii:radii];
     self.layer.mask = tMaskLayer;
     }
  
    - (CALayer*)maskForRoundedCorners:(UIRectCorner)corners withRadii:(CGSize)radii {
      CAShapeLayer *maskLayer = [CAShapeLayer layer];
      maskLayer.frame = self.bounds;
  
    UIBezierPath *roundedPath = [UIBezierPath bezierPathWithRoundedRect:
                               maskLayer.bounds byRoundingCorners:corners cornerRadii:radii];
      maskLayer.fillColor = [[UIColor whiteColor] CGColor];
      maskLayer.backgroundColor = [[UIColor clearColor] CGColor];
      maskLayer.path = [roundedPath CGPath];
  
     return maskLayer;
   }
  </code></pre>