前言:我的需求是要求一個(gè)矩形背景刑峡,左上和右上是直角的纵菌,左下和右下是圓角的矩形背景阐污。
效果圖:
// 畫出背景的圓角,注意:必須在frame后面設(shè)置才有效
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;