iOS ,给矩形背景的任意一角添加圆角

2018-11-26  本文已影响0人  最强的小强

前言:我的需求是要求一个矩形背景,左上和右上是直角的,左下和右下是圆角的矩形背景。

效果图:


屏幕快照 2018-11-26 16.28.23.png
// 画出背景的圆角,注意:必须在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;
上一篇 下一篇

猜你喜欢

热点阅读