Skip to content

Instantly share code, notes, and snippets.

@jellyZ
Forked from bobmoff/UIView+RoundedCorners.h
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jellyZ/e556b88210e4183215f1 to your computer and use it in GitHub Desktop.
Save jellyZ/e556b88210e4183215f1 to your computer and use it in GitHub Desktop.
UIView 圆角
#import <UIKit/UIKit.h>
@interface UIView (RoundedCorners)
- (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size;
@end
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment