Skip to content

Instantly share code, notes, and snippets.

@nonstriater
Created May 4, 2014 06:11
Show Gist options
  • Save nonstriater/20ddc933f6147265f6dd to your computer and use it in GitHub Desktop.
Save nonstriater/20ddc933f6147265f6dd to your computer and use it in GitHub Desktop.
为UIView设置圆角(小于4个角)
为UIView设置圆角(小于4个角) UIBezi erPath + UIShapeLayer
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)]; // byRoundingCorners : 指定需要圆角的角,UIRectCorner类型
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view2.bounds;
maskLayer.path = maskPath.CGPath;
view2.layer.mask = maskLayer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment