前言:我的需求是要求一个矩形背景,左上和右上是直角的,左下和右下是圆角的矩形背景。
效果图:
// 画出背景的圆角,注意:必须在frame后面设置才有效
UIBezierPath *fieldPath = [UIBezierPath bezierPathWithRoundedRect:yuyiBgView.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerBottomLeft cornerRadii:CGSizeMake(8 , 8)];
CAShapeLayer *fieldLayer = [[CAShapeLayer alloc] init];
fieldLayer.frame = yuyiBgView.bounds;
fieldLayer.path = fieldPath.CGPath;
yuyiBgView.layer.mask = fieldLayer;