Skip to content

Instantly share code, notes, and snippets.

@jagregory
Created January 22, 2013 10:54
Show Gist options
  • Save jagregory/4593780 to your computer and use it in GitHub Desktop.
Save jagregory/4593780 to your computer and use it in GitHub Desktop.

Revisions

  1. jagregory created this gist Jan 22, 2013.
    5 changes: 5 additions & 0 deletions UIView+Corners.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    @interface UIView(Corners)

    - (void)cornerRadius:(float)radius forCorners:(UIRectCorner)corners;

    @end
    14 changes: 14 additions & 0 deletions UIView+Corners.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #import <QuartzCore/QuartzCore.h>
    #import "UIView+Corners.h"

    @implementation UIView(Corners)

    -(void)cornerRadius:(float)radius forCorners:(UIRectCorner)corners{
    CAShapeLayer* mask = [CAShapeLayer layer];
    mask.path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
    byRoundingCorners:corners
    cornerRadii:CGSizeMake(radius, radius)].CGPath;
    self.layer.mask = mask;
    }

    @end