【发布时间】:2018-10-19 22:56:35
【问题描述】:
我有一个collectionviewcell cell,我正在添加一个CAShapeLayer 给我的frontImageView 一个半边框。我现在成功创建的代码创建了一个半边框,但不是我想要的。设置stokeEnd=0.5 在我的imageView 底部创建一个半边框。我希望边框位于 imageView 的右侧。从顶部中心到底部中心(右侧)。
我可以沿着右侧从 imageView 的顶部中心到底部中心绘制笔划线吗?
CAShapeLayer *shape = [CAShapeLayer layer];
UIBezierPath *path=[UIBezierPath bezierPathWithOvalInRect:cell.frontImageView.frame];
[shape setPath:path.CGPath];
shape.strokeColor=[UIColor purpleColor].CGColor;
shape.fillColor=[UIColor clearColor].CGColor;
shape.lineWidth = 5.0f;
shape.lineCap = kCALineCapRound;
[shape setStrokeEnd:0.5];
[cell.layer addSublayer:shape];
【问题讨论】:
-
这很容易。添加变换以旋转形状图层。
标签: ios objective-c cashapelayer