半邊角和帶邊框

只流傳著如何設置半角。但是沒有設置描邊。方法如下:

貝塞爾曲線

//TODO:uiview單邊圓角或者單邊框

CGRect layerFrame=self.addBtn.bounds;

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:layerFrame byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight) cornerRadii:CGSizeMake(5,5)];//圓角大小

//設置遮罩

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

maskLayer.frame = layerFrame;

maskLayer.path= maskPath.CGPath;

//設置邊框

CAShapeLayer *borderLayer = [[CAShapeLayer alloc] init];

borderLayer.frame = layerFrame;

borderLayer.path= maskPath.CGPath;

borderLayer.fillColor = [UIColor clearColor].CGColor;

borderLayer.lineWidth=2;

borderLayer.strokeColor = [UIColor blueColor].CGColor;

borderLayer.strokeStart = 0.f;

borderLayer.strokeEnd = 1.f;

self.addBtn.layer.mask = maskLayer;

[self.addBtn.layer addSublayer:borderLayer];

self.addBtn.backgroundColor=[UIColor redColor];

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容