Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
UIView maskByRoundingCorners:cornerRadius:
#import "UIView+TDKUtil.h"
@implementation UIView (TDKUtil)
- (void)maskByRoundingCorners:(UIRectCorner)corners
[self layoutIfNeeded];
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
CAShapeLayer *maskLayer = [CAShapeLayer new];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.