iOS开发iOS 菜鸟之旅

使用UIBezierPath,CAShapeLayer画虚线

2017-07-20  本文已影响63人  涛涛灬灬

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 0)];
[path addLineToPoint:CGPointMake(self.width-30, 0)];

_shapeLine = [CAShapeLayer layer];
_shapeLine.frame = CGRectMake(15, self.bottom - 1, self.width-30, 0.5);
_shapeLine.lineJoin = kCALineJoinRound;
_shapeLine.lineDashPattern = @[@(5),@(5)];
_shapeLine.fillColor = [UIColor clearColor].CGColor;
    _shapeLine.strokeColor = kCYTCardLineColor.CGColor;
_shapeLine.path = path.CGPath;
[self.layer addSublayer:_shapeLine];
上一篇下一篇

猜你喜欢

热点阅读