Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BetrayalPromise/65ed4aa36e00a9b34f2a8a60a79677a7 to your computer and use it in GitHub Desktop.

Select an option

Save BetrayalPromise/65ed4aa36e00a9b34f2a8a60a79677a7 to your computer and use it in GitHub Desktop.

Revisions

  1. Fille created this gist Jul 10, 2013.
    7 changes: 7 additions & 0 deletions UIView+RoundedCorners.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #import <UIKit/UIKit.h>

    @interface UIView (RoundedCorners)

    - (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size;

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

    @implementation UIView (RoundedCorners)

    - (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size {
    UIBezierPath* maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:size];

    CAShapeLayer* maskLayer = [CAShapeLayer new];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;

    self.layer.mask = maskLayer;

    }

    @end